Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions retrying.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def __init__(self,
wait_func=None,
wait_jitter_max=None,
before_attempts=None,
after_attempts=None):
after_attempts=None,
print_exception=None):

self._stop_max_attempt_number = 5 if stop_max_attempt_number is None else stop_max_attempt_number
self._stop_max_delay = 100 if stop_max_delay is None else stop_max_delay
Expand All @@ -92,6 +93,7 @@ def __init__(self,
self._wait_jitter_max = 0 if wait_jitter_max is None else wait_jitter_max
self._before_attempts = before_attempts
self._after_attempts = after_attempts
self._print_exception = print_exception

# TODO add chaining of stop behaviors
# stop behavior
Expand Down Expand Up @@ -223,7 +225,9 @@ def call(self, fn, *args, **kwargs):

try:
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
except:
except Exception as expt:
if self._print_exception:
print(expt)
tb = sys.exc_info()
attempt = Attempt(tb, attempt_number, True)

Expand Down