You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from retry import retry
import logging
logger = logging.getLogger()
@retry((Exception,), tries=2, logger=logger)
def raise_error_generator():
raise Exception('error')
ret = []
for i in range(5):
ret.append(i)
return ret
def my_func():
for i in raise_error_generator():
print(i)
my_func()
...which gives:
error, retrying in 0 seconds...
Traceback (most recent call last):
File "test_retry_decorator.py", line 19, in <module>
my_func()
File "test_retry_decorator.py", line 16, in my_func
for i in raise_error_generator():
File "<decorator-gen-2>", line 2, in raise_error_generator
File "/Users/alcanno/.virtualenvs/facebook3/lib/python3.7/site-packages/retry/api.py", line 74, in retry_decorator
logger)
File "/Users/alcanno/.virtualenvs/facebook3/lib/python3.7/site-packages/retry/api.py", line 33, in __retry_internal
return f()
File "test_retry_decorator.py", line 9, in raise_error_generator
raise Exception('error')
Exception: error
vs:
from retry import retry
import logging
logger = logging.getLogger()
@retry((Exception,), tries=2, logger=logger)
def raise_error_generator():
raise Exception('error')
for i in range(5):
yield i
def my_func():
for i in raise_error_generator():
print(i)
my_func()
...which gives (note the lack of the log message from the retry decorator, indicating the function was not retried).
Traceback (most recent call last):
File "test_retry_decorator.py", line 17, in <module>
my_func()
File "test_retry_decorator.py", line 14, in my_func
for i in raise_error_generator():
File "test_retry_decorator.py", line 9, in raise_error_generator
raise Exception('error')
Exception: error
The text was updated successfully, but these errors were encountered:
Consider:
...which gives:
vs:
...which gives (note the lack of the log message from the retry decorator, indicating the function was not retried).
The text was updated successfully, but these errors were encountered: