Skip to content

Commit

Permalink
Show attempt numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomer Shalev committed Aug 2, 2021
1 parent c3f386a commit 606e01b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion retry/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ def __retry_internal(f, exceptions=Exception, tries=-1, delay=0, max_delay=None,
except exceptions as e:
_tries -= 1
if not _tries:
if logger is not None and tries > 1:
logger.warning('%s, attempt %s/%s failed - giving up!', e, tries - _tries, tries)
raise

if logger is not None:
logger.warning('%s, retrying in %s seconds...', e, _delay)
logger.warning('%s, attempt %s/%s failed - retrying in %s seconds...', e, tries - _tries, tries, _delay)

time.sleep(_delay)
_delay *= backoff
Expand Down

0 comments on commit 606e01b

Please sign in to comment.