let's say I have the following function:
@retry(stop=stop_after_attempt(3))
def foo():
try:
response = requests.post(...)
response.raise_for_status()
return response
except Exception as e:
raise e
This function will retry 3 times, and if all three retries fail, an exception will be raised.
How can I use tenacity to do 3 retries without raising the exception? Something like:
@retry(stop=stop_after_attempt(3))
def foo(ignore_errors=False):
try:
response = requests.post(...)
response.raise_for_status()
return response
except Exception as e:
if ignore_errors and function has been retried three times:
pass
raise e