-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nesting multiple decorators breaks waiting times #91
Comments
Thanks a lot for your answer! Should I submit a PR to update this section of the docs? I find this behavior is not intuitive (at least for me). |
So I think your original report was correct, and I was confused because full_jitter was on. Full jitter can cause the value to go down from one retry to the next, but the behavior your were citing is real independent of jitter. Here's an example with jitter disabled:
You can see that each exception type gets its own wait sequence. This is because each decorator defines and instantiates its own wait generator. I think this is probably unavoidable, and probably(?) desirable. Consider if you wanted to do exponential backoff for one type of exception and constant backoff for another. I think you're right that at the least it could be documented better. At of curiosity, do you have a real world case where you wanted to define different behavior for different exceptions? |
Woah, I just looked at my own at example more carefully and it's weirder than that. The KeyError wait generator is getting reset each time. I think combining decorators doesn't work as neatly as was supposed. :/ |
Yes, just hitting an API and if I get an exception related with bad formatting I don't want to retry, but if I hit any other exception I want to back off exponentially. |
Look at this simple example and notice the waiting times does not increase as expected:
(see the 0.5 seconds in the 4th log)
If we just leave one exponential backoff now behaves as expected:
Tested with
backoff ==1.8.1
and saw no relevant changes in the changelog since then.The text was updated successfully, but these errors were encountered: