Closed
Description
I'm trying to upgrade backoff
from v1.11.x
to v2.1.0
but blocked by an error when passing callable to max_time
argument, as seen in the example below:
import backoff
def lookup_max_time():
return 30
@backoff.on_exception(
backoff.constant,
ValueError,
max_time=lookup_max_time,
)
def wait_for(*args, **kwargs):
raise ValueError("err")
if __name__ == "__main__":
wait_for()
Here's the traceback:
Traceback (most recent call last):
File "/home/iromli/contrib/backoff/backoff/_sync.py", line 104, in retry
ret = target(*args, **kwargs)
File "/home/iromli/contrib/backoff/dist/testing_backoff.py", line 14, in wait_for
raise ValueError("err")
ValueError: err
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/iromli/contrib/backoff/dist/testing_backoff.py", line 18, in <module>
wait_for()
File "/home/iromli/contrib/backoff/backoff/_sync.py", line 117, in retry
seconds = _next_wait(wait, e, jitter, elapsed, max_time)
File "/home/iromli/contrib/backoff/backoff/_common.py", line 54, in _next_wait
seconds = min(seconds, max_time - elapsed)
TypeError: unsupported operand type(s) for -: 'function' and 'float'
It seems that when calling _next_wait
function, the max_time
value is the callable instead of the actual value returned by callable.
Thanks..
Activity
bgreen-litl commentedon Jun 8, 2022
Thank you. This is now fixed and released in backoff 2.1.1