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
Hello
We observed breaking change in @retry decorator behavior after upgrading the library from 8.2.3 to 8.3.0/8.4.1 version.
Assuming the next code sample (simplified and adjusted to illustrate the exact use-case):
fromtenacityimportRetryCallState, retryMAX_RETRY_FIX_ATTEMPTS=2defdo_retry(retry_state: RetryCallState):
ex=retry_state.outcome.exception()
_subject_: str=retry_state.args[0]
if_subject_=='Fix': # no retry on fix failurereturnFalseifretry_state.attempt_number>=MAX_RETRY_FIX_ATTEMPTS:
returnFalseifex:
do_fix_work()
returnTruereturnFalse@retry(reraise=True, retry=do_retry)def_do_work(subject: str):
ifsubject=='Error':
print(f'{subject} is not working')
raiseException(f'{subject} is not working')
print(f'{subject} is working')
defdo_any_work(subject: str):
_do_work(subject)
defdo_fix_work():
_do_work('Fix')
if__name__=='__main__':
do_any_work('Error')
In version 8.2.3 it worked correctly means do_any_work function was called twice with do_fix_work in the middle and produced the next output:
Error is not working
Fix is working
Error is not working
Traceback (most recent call last):
...call-stack...
Exception: Error is not working
After upgrading to 8.3.0 or 8.4.1 the code is not working the same way.
There's no additional call of do_any_work after do_fix_work and the code does not end with error:
Error is not working
Fix is working
Process finished with exit code 0
The text was updated successfully, but these errors were encountered:
Just opened a fix in #479, looks like we were overwriting a local context when recursively calling a decorated function, sorry about that! @jd let me know if that looks ok to you :)
Hello
We observed breaking change in
@retry
decorator behavior after upgrading the library from 8.2.3 to 8.3.0/8.4.1 version.Assuming the next code sample (simplified and adjusted to illustrate the exact use-case):
In version 8.2.3 it worked correctly means
do_any_work
function was called twice withdo_fix_work
in the middle and produced the next output:After upgrading to 8.3.0 or 8.4.1 the code is not working the same way.
There's no additional call of
do_any_work
afterdo_fix_work
and the code does not end with error:Error is not working Fix is working Process finished with exit code 0
The text was updated successfully, but these errors were encountered: