diff --git a/retrying.py b/retrying.py index bcb7a9d..41b31ed 100644 --- a/retrying.py +++ b/retrying.py @@ -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 @@ -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 @@ -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)