From adc4247efd7239d396a8f0db75b8a5632707acc6 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 20 Nov 2020 13:29:33 -0800 Subject: [PATCH] Add Backoff.current to get value without stepping forward. --- voussoirkit/backoff.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/voussoirkit/backoff.py b/voussoirkit/backoff.py index 124c49d..461710f 100644 --- a/voussoirkit/backoff.py +++ b/voussoirkit/backoff.py @@ -24,10 +24,14 @@ class Backoff: raise ValueError(f'max must be positive, not {max}.') self.max = max - def next(self): + def current(self): y = self._calc() if self.max is not None: y = min(y, self.max) + return y + + def next(self): + y = self.current() self.x += 1 return y