-
-
Notifications
You must be signed in to change notification settings - Fork 303
Closed
Description
On using retry_unless_exception_type , retry is always called (despite a successful run) until the exception(s) is(are) encountered. However, correct behavior with this condition should be to retry only if a function has failed due to some exception other than the ones mentioned in the retry condition.
e.g. This is the function definition, wherein I want to retry the function only if the exception is not among psycopg2.ProgrammingError and NameError and either the time since last retrial is less than 1 min, or the attempt count is less than 3:
@retry(stop=(stop_after_delay(60) | stop_after_attempt(2)),
reraise=True,
retry=retry_unless_exception_type((psycopg2.ProgrammingError, NameError)))
def run_query(query_variable):
cursor.execute(query_variable)
print cursor.rowcount
print "Done"
and here's the execution log, which shows that function was retried twice despite successful runs:
53059
Done
53059
Done
Traceback (most recent call last):
File "update_offer_base_item_mapping.py", line 22, in <module>
run_query(a)
File "/Users/grofers/Documents/cb/py2venv/lib/python2.7/site-packages/tenacity/__init__.py", line 241, in wrapped_f
return self.call(f, *args, **kw)
File "/Users/grofers/Documents/cb/py2venv/lib/python2.7/site-packages/tenacity/__init__.py", line 330, in call
start_time=start_time)
File "/Users/grofers/Documents/cb/py2venv/lib/python2.7/site-packages/tenacity/__init__.py", line 297, in iter
raise retry_exc.reraise()
File "/Users/grofers/Documents/cb/py2venv/lib/python2.7/site-packages/tenacity/__init__.py", line 137, in reraise
raise self
tenacity.RetryError: RetryError[<Future at 0x109cf4190 state=finished returned NoneType>]
yuvadm and hoffa
Metadata
Metadata
Assignees
Labels
No labels