Add support for async strategies and callbacks #433
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #249
Follows up on #289 #363
I took a stab at DRYing the
iter()
function in order to supportasync
callbacks, and once those were possible, I thought it would also make sense to allow forasync
strategies.The approach I have taken is to build a list of actions that
iter()
needs to go through, where each action is just a piece of the whole current logic, and each step can further extend the list of actions. 3 pieces have been taken out to redefine in specific Retrying implementations, i.e.asyncio
. This way we can make sure we use coroutines for those calls, as well as dynamically wrapping each function as a coroutine, allowing for both sync and async strategies and callbacks.I tried to make somewhat meaningful commits, it should be easier to review commit-by-commit.
I appreciate the new approach looks quite odd and is not very intuitive to follow, happy to take some feedback and improve it if anyone has some other ideas.