-
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
Add return-value/exception based backoff time #124
Add return-value/exception based backoff time #124
Conversation
I like this! I like how you set up I think this is on the right track. My one concern is: Does this change the contract for the wait_gen parameter such that the generator function now must start with that naked
If so, is there a way to make this style of wait generator function work as well? |
@bgreen-litl we could check if the
Such a generator necessarily has to have a dangling This way this is fully backwards compatible with any custom generators that don't live in this repo. What I don't like about this is that if we ever change the word |
Alternatively we could include the first exception/return in the |
@bgreen-litl sorry to keep nagging :) any thoughts on this? |
I apologize for the very delayed response. I've been swamped with other things. On reflection, I think the benefit of this (a clean way to handle Retry-After) outweighs the potential backward compatibility issue. I don't think we should jump through any hoops testing for Thanks again for this work. |
Thanks @bgreen-litl, very exciting! I'll work on adding these docs soon. |
I merged these commits to master. Thanks for this! |
@bgreen-litl thank you and apologies for never coming back around to this! been a super hectic 3 months |
@bgreen-litl Any idea of when we can expect a new release with this change? I'd like to use this feature in multiple projects and would like to avoid specifying a Git URL in my requirements.txt if possible :) |
This is available in backoff 2.0.0 via the |
Closes #102
Take 2 of #122 this time using @bgreen-litl 's awesome suggestion to use
.send
.The code is much cleaner and easier to use. The approach is to:
on_exception
) or return value (if usingon_predicate
) to the wait time generatorTo make this easy to use I added a new generator
from_value
which takes a callable whose input is the exception or decoratee-return-value, and whose return value is length of time to wait.The consumer can use the new generator by doing:
Questions:
test_wait_gen.py
for the new generator. Are there any additional test cases you'd recommend? Maybe something to verify that if the return value from the input callable is not a valid number (e.g: non-negative) that the appropriate exception is thrown?If this approach looks good I'll add docs and any more tests you recommend.