-
-
Notifications
You must be signed in to change notification settings - Fork 281
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
Allow asynchronous callbacks for AsyncRetrying parameters #363
base: main
Are you sure you want to change the base?
Conversation
13657ee
to
f65ca57
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we try to DRY the iter
method? I understand we need to re-define it but it'd be great if we could share most of the code.
return await func(retry_state) | ||
return func(retry_state) | ||
|
||
async def iter(self, retry_state: "RetryCallState") -> typing.Union[DoAttempt, DoSleep, typing.Any]: # noqa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jd I also wanted to use some base method to avoid re-defining the iter method again, however, one of them is sync def iter
and other one is async async def iter
. Any ideas how to make it DRY?
I wanted to use handle_custom_function
to handle sync/async calls, however, if we make handle_custom_function
sync function, then it might need to use asyncio.get_event_loop()
to run awaitable functions (running async functions from sync function).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jd any ideas? I would love to have a progress with this PR and start using async callbacks for retry_error_callback
This change will allow both async and sync functions to be used as callable parameters for Async retries.
Docs are not updated, please, inform if any other changes are needed. Thank you very much for your review.
Fixes #249