Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.

Commit b1a5a53

Browse files
author
Bob Green
committed
Handle wait_gen_kwargs which take an argument
All wait_gen args are subject to maybe_call() as a way to dynamically look up a value at runtime. These callables do not take an argument. If a callable which takes an argument is passed (as is the case with the `value` kwargs for the `runtime` wait generator, we pass through the function.
1 parent ed932f7 commit b1a5a53

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

backoff/_common.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515

1616
# Evaluate arg that can be either a fixed value or a callable.
1717
def _maybe_call(f, *args, **kwargs):
18-
return f(*args, **kwargs) if callable(f) else f
18+
if callable(f):
19+
try:
20+
return f(*args, **kwargs)
21+
except TypeError:
22+
return f
23+
else:
24+
return f
1925

2026

2127
def _init_wait_gen(wait_gen, wait_gen_kwargs):

0 commit comments

Comments
 (0)