Works in Try block?
jaoxford opened this issue · comments
Hi there,
I'm curious to know if this library will work when a function is called from within a try block?
If an exception happens inside the function being called will the except block be called, or only if the retries happen to fail?
try:
foo()
except Exception:
print(Exception)
@retry(
retry_on_exceptions=(FooException),
max_calls_total=3,
retry_window_after_first_call_in_seconds=60,
)
def foo():
This pattern is used in the testcases.
Lines 41 to 69 in dc7ac01
As we can see from the assert statements the counter is incremented to 3 before the block in the except statement is called.
If you want to log the exceptions that occur in foo
they should be logged from the inside.
@retry(
retry_on_exceptions=(FooException),
max_calls_total=3,
retry_window_after_first_call_in_seconds=60,
)
def wrap_foo:
try:
foo()
except Exception as e:
log(e)
raise e
def foo:
pass
Lovely, thank you!