In the link https://tenacity.readthedocs.io/en/latest/ the below example states that the wait between retries will be 2*1 (capped at 10 seconds), but should not this be a linear growth when the multiplier is 1.
@retry(wait=wait_exponential(multiplier=1, min=4, max=10))
def wait_exponential_1():
print("Wait 2^x * 1 second between each retry starting with 4 seconds, then up to 10 seconds, then 10 seconds afterwards")
raise Exception
The formula is 2^x * multiplier
and, in this particular example, the multiplier is 1 (which is a bit confusing for an example).
Do not mistake the multiplier with the exponent (x
): 2^x
is still exponentiation.
Specifically because it uses 2^x
, this retry wait is called "binary exponential backoff". (also confusing; in this situation, 2 is the "multiplicative factor" or "base" of exponenation, but that's different than the multiplier
argument; multiplication happens after exponentiation)
So if x
is the index of the retry attempt (starting with 0), then the value of 2^x
is shown in the second column of the table below...
Multiply the value of 2^x
by either multiplier=1
, or 2
, or 3
, to see how long it will wait before retrying each attempt...
x | 2^x | if multiplier is... 1 | ...2 | ...3 |
---|---|---|---|---|
0 | 1 | then wait ... 1 | 2 | 3 |
1 | 2 | 2 | 4 | 6 |
2 | 4 | 4 | 8 | 12 |
3 | 8 | 8 | 16 | 24 |