Zero exponential multiplier can overflow into maximum wait
Setting an exponential multiplier to zero can unexpectedly produce the maximum wait after enough attempts. I reproduced this on main (3e58094d3) with Python 3.13.13:
from types import SimpleNamespace
from tenacity import wait_exponential, wait_exponential_jitter
state = SimpleNamespace(attempt_number=1025)
print(wait_exponential(multiplier=0.0, max=60)(state))
print(wait_exponential(multiplier=0, exp_base=2.0, max=60)(state))
print(wait_exponential_jitter(multiplier=0.0, jitter=0, max=60)(state))All three calls return 60.0; the expected wait is zero. With a configured minimum, the zero exponential contribution should leave that minimum in effect. The jitter strategy should also retain its random contribution.
The power is calculated before multiplication by zero. A floating-point power can overflow; multiplying the large integer power by 0.0 also overflows while converting that integer to a float. Both paths fall into the overflow handler and use the maximum. wait_random_exponential inherits the same upper-bound problem.
This makes a configured zero backoff begin waiting at the cap after many retries. A bounded regression at attempt 1025 reproduces the behavior without sleeping or performing any retries.
OpenAI Codex assisted with investigation, reproduction, and this report.
Source: jd/tenacity