Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Add async strategies #451

wants to merge 7 commits into from

Conversation

hasier
Copy link
Contributor

@hasier hasier commented Mar 18, 2024

Third and last PR after breaking down #433 (follows hasier#1 #437)

After DRYing the iter() function and making AsyncRetrying support async callbacks, add new async strategies (basically a copy-paste) and improve typing.

Supersedes hasier#2

Copy link
Contributor

mergify bot commented Mar 18, 2024

⚠️ No release notes detected. Please make sure to use reno to add a changelog entry.

Comment on lines 82 to 85
def __init__(
self, predicate: typing.Callable[[typing.Any], typing.Awaitable[bool]]
) -> None:
super().__init__(predicate) # type: ignore[arg-type]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?

Copy link
Contributor Author

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.

Copy link
Owner

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.

Copy link
Contributor Author

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?

Copy link
Owner

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hahah fair, done! 927965d

tenacity/retry.py Show resolved Hide resolved
@hasier hasier requested a review from jd April 9, 2024 08:31
@jd
Copy link
Owner

jd commented May 7, 2024

@hasier sorry for the long delay, that PR slipped my mind. Don't hesitate to harass me more for reviews.

@hasier
Copy link
Contributor Author

hasier commented May 23, 2024

@jd sorry, I've been busy these last few days, could you take another look at my latest comment? 🙏

@hasier
Copy link
Contributor Author

hasier commented Jun 3, 2024

@jd any idea what might be going on with the Tornado tests? https://github.com/jd/tenacity/actions/runs/9347251510/job/25723863307?pr=451

@jd
Copy link
Owner

jd commented Jun 3, 2024

I think it's #460

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants