From 12a0c818196b562fef4bb622214978618298835e Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 3 May 2021 18:32:18 -0700 Subject: [PATCH] Add docstrings to Backoff class's methods. --- voussoirkit/backoff.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/voussoirkit/backoff.py b/voussoirkit/backoff.py index 56c2188..1b7c32e 100644 --- a/voussoirkit/backoff.py +++ b/voussoirkit/backoff.py @@ -26,22 +26,35 @@ class Backoff: self.max = max def current(self): + ''' + Return the current backoff value without advancing. + ''' y = self._calc() if self.max is not None: y = min(y, self.max) return y def next(self): + ''' + Return the current backoff value, then advance x. + ''' y = self.current() self.x += 1 return y - def rewind(self, steps): - self.x = max(0, self.x - steps) - def reset(self): + ''' + Reset x to 0. + ''' self.x = 0 + def rewind(self, steps): + ''' + Subtract this many steps from x, to ease up the backoff without + entirely resetting. + ''' + self.x = max(0, self.x - steps) + #################################################################################################### class Exponential(Backoff):