Skip to content

Commit

Permalink
Use maybe-called keyword values everywhere
Browse files Browse the repository at this point in the history
We were still passing in the maybe callable original arg rather than
using the looked-up value in a couple places.
  • Loading branch information
bgreen-litl committed Jun 8, 2022
1 parent 2776b3a commit b87ebb6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions backoff/_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ def retry(*args, **kwargs):
ret = target(*args, **kwargs)
if predicate(ret):
max_tries_exceeded = (tries == max_tries_value)
max_time_exceeded = (max_time is not None and
max_time_exceeded = (max_time_value is not None and
elapsed >= max_time_value)

if max_tries_exceeded or max_time_exceeded:
_call_handlers(on_giveup, **details, value=ret)
break

try:
seconds = _next_wait(wait, ret, jitter, elapsed, max_time)
seconds = _next_wait(wait, ret, jitter, elapsed,
max_time_value)
except StopIteration:
_call_handlers(on_giveup, **details)
break
Expand Down Expand Up @@ -104,7 +105,7 @@ def retry(*args, **kwargs):
ret = target(*args, **kwargs)
except exception as e:
max_tries_exceeded = (tries == max_tries_value)
max_time_exceeded = (max_time is not None and
max_time_exceeded = (max_time_value is not None and
elapsed >= max_time_value)

if giveup(e) or max_tries_exceeded or max_time_exceeded:
Expand All @@ -114,7 +115,8 @@ def retry(*args, **kwargs):
return None

try:
seconds = _next_wait(wait, e, jitter, elapsed, max_time)
seconds = _next_wait(wait, e, jitter, elapsed,
max_time_value)
except StopIteration:
_call_handlers(on_giveup, **details)
raise e
Expand Down

0 comments on commit b87ebb6

Please sign in to comment.