Name Description Size
__init__.py A generator function that sleeps between retries, handles exponential backoff and jitter. The action you are retrying is meant to run after retrier yields. At each iteration, we sleep for sleeptime + random.uniform(-jitter, jitter). Afterwards sleeptime is multiplied by sleepscale for the next iteration. Args: attempts (int): maximum number of times to try; defaults to 5 sleeptime (float): how many seconds to sleep between tries; defaults to 10 seconds max_sleeptime (float): the longest we'll sleep, in seconds; defaults to 300s (five minutes) sleepscale (float): how much to multiply the sleep time by each iteration; defaults to 1.5 jitter (float): random jitter to introduce to sleep time each iteration. the amount is chosen at random between [-jitter, +jitter] defaults to 1 Yields: None, a maximum of `attempts` number of times Example: >>> n = 0 >>> for _ in retrier(sleeptime=0, jitter=0): ... if n == 3: ... # We did the thing! ... break ... n += 1 >>> n 3 >>> n = 0 >>> for _ in retrier(sleeptime=0, jitter=0): ... if n == 6: ... # We did the thing! ... break ... n += 1 ... else: ... print("max tries hit") max tries hit 8518
cmd.py 2085