Allow on
to be a predicate: typing.Callable[[BaseException], bool]
#63
Replies: 4 comments 1 reply
-
I think this is reasonable. I would like to retry in case the downstream service started throttling (429's). I understand this is possible with tenacity, but not with stamina due to the above? |
Beta Was this translation helpful? Give feedback.
-
I would be open to a PR, but bear in mind I'm leaving for a vacation tomorrow so merging might take some time! |
Beta Was this translation helpful? Give feedback.
-
Enjoy the vacation! 🌴 No rush on this (for me at least). I'll try to find the time to put in a PR. It should be fairly straightforward.... I think! |
Beta Was this translation helpful? Give feedback.
-
I'm dealing with a library where I want to retry an exception only if the message contains a certain string.
I think the most flexible way to support this whilst being backward compatible would be to change the
on
argument to allow passing in apredicate
callable - e.g.:In the
retry
code you can then create thepredicate
like:...and then in
_RetryContextIterator
pass it through totenacity
as:xref: https://github.com/jd/tenacity/blob/main/tenacity/retry.py#L62-L78
Beta Was this translation helpful? Give feedback.
All reactions