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

Rewrite asyncio.wait_for using asyncio.timeout #96764

Closed
kumaraditya303 opened this issue Sep 12, 2022 · 8 comments · Fixed by #98518
Closed

Rewrite asyncio.wait_for using asyncio.timeout #96764

kumaraditya303 opened this issue Sep 12, 2022 · 8 comments · Fixed by #98518
Assignees
Labels
3.12 bugs and security fixes topic-asyncio type-feature A feature request or enhancement

Comments

@kumaraditya303
Copy link
Contributor

kumaraditya303 commented Sep 12, 2022

Over the years a lot of issues have accumulated for asyncio.wait_for and the code has become complicated. The asyncio.timeout can be used to simplify this a lot and will also fix bugs which are already fixed or don't exist in asyncio.timeout. This rewrite won't be backported. asyncio.wait_for should be nothing more than a wrapper around asyncio.timeout.

asyncio.wait_for issues: https://github.com/python/cpython/issues?q=is%3Aissue+is%3Aopen+wait_for+label%3Aexpert-asyncio

Linked PRs

@kumaraditya303 kumaraditya303 added type-feature A feature request or enhancement topic-asyncio 3.12 bugs and security fixes labels Sep 12, 2022
@kumaraditya303 kumaraditya303 moved this to Todo in asyncio Sep 12, 2022
@gvanrossum
Copy link
Member

Note that whatever we do should preserve all the existing behavior in wait_for(). Breaking existing code using it would be worse than keeping a bunch of issues that people can avoid by switching to using timeout() directly.

@kumaraditya303
Copy link
Contributor Author

@graingert IIRC you had a branch for this, interested in this?

@graingert
Copy link
Contributor

Yeah I'm interested, but one thing to note is that wait_for has changed dramatically between versions so matching the behavior is hard

@kumaraditya303
Copy link
Contributor Author

Yeah I'm interested, but one thing to note is that wait_for has changed dramatically between versions so matching the behavior is hard

It can be evaluated by checking how many tests it breaks by just changing it to use asyncio.timeout and take it from there.

@graingert
Copy link
Contributor

#31847 (comment) here's the work so far

@eIGato
Copy link

eIGato commented Mar 14, 2023

When can we expect it to be released?
And under what patch number?

@gvanrossum
Copy link
Member

3.12

@cretz
Copy link

cretz commented Nov 9, 2023

Just want to note on this issue that this change is an unfortunate compatibility break in our Temporal deterministic event loop implementation. We can deterministically implement call_later because it's relative time, but now wait_for uses fixed time of call_at which our time-travelling event loop can't support. I am looking into options...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes topic-asyncio type-feature A feature request or enhancement
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants