eSAMTrade / retry

easy to use retry decorator in python
Other
28 stars 9 forks source link

Introduce a new option 'skip_retry' #11

Closed jonathan-s closed 1 year ago

jonathan-s commented 1 year ago

If skip_retry is a function and that function returns true No more retries are happening. This is particularly useful when you know there are errors where another retry is not only not necessary, but can be actively harmful.

I acknowledge that there is a work around with using on_exception using the following construct.

try:
    some code
except ErrorThrown as e:
    if e.condition:
        raise ErrorThatWillBeIgnoredByRetry

However, that would require a fair bit of rewriting, it would be neater if you could set conditions in the skip_retry function and if those conditions are fulfilled no retries would be done.