-
-
Notifications
You must be signed in to change notification settings - Fork 267
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 async strategies #451
base: main
Are you sure you want to change the base?
Add async strategies #451
Conversation
|
473c081
to
3c5f788
Compare
tenacity/asyncio/retry.py
Outdated
def __init__( | ||
self, predicate: typing.Callable[[typing.Any], typing.Awaitable[bool]] | ||
) -> None: | ||
super().__init__(predicate) # type: ignore[arg-type] |
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.
Is this really needed?
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.
Not strictly, but it helps with the typing, otherwise mypy
and similar tools would complain about async functions.
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.
Right, that does not look good though.
I think self.predicate
is going to have different types than the one defined in retry_base
. I think we might need to not use retry_base
or simply use a different async base.
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.
That's fair. I mainly wanted to keep it dry and reuse as much as possible. Would you rather have a whole new (mainly copy-paste) async implementation for these cases then?
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.
I think it'd be better. As we started to type everything, I know from experience that trying to be smarter than mypy ends up haunting you at some point.
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.
hahah fair, done! 927965d
@hasier sorry for the long delay, that PR slipped my mind. Don't hesitate to harass me more for reviews. |
@jd sorry, I've been busy these last few days, could you take another look at my latest comment? 🙏 |
@jd any idea what might be going on with the Tornado tests? https://github.com/jd/tenacity/actions/runs/9347251510/job/25723863307?pr=451 |
I think it's #460 |
Third and last PR after breaking down #433 (follows
hasier#1#437)Support async actions hasier/tenacity#1Support async actions #437After DRYing the
iter()
function and makingAsyncRetrying
supportasync
callbacks, add newasync
strategies (basically a copy-paste) and improve typing.Supersedes hasier#2