Skip to content

Rewrite asyncio.wait_for using asyncio.timeout #96764

Description

@kumaraditya303

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

Activity

  1. gvanrossum commented on Sep 12, 2022

    @gvanrossum
    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.

  2. kumaraditya303 commented on Sep 17, 2022

    @kumaraditya303
    ContributorAuthor

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

  3. graingert commented on Sep 17, 2022

    @graingert
    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

  4. kumaraditya303 commented on Sep 17, 2022

    @kumaraditya303
    ContributorAuthor

    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.

  5. graingert commented on Sep 17, 2022

    @graingert
    Contributor

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

  6. moved this from Todo to Done in asyncioon Feb 16, 2023
  7. added a commit that references this issue on Feb 16, 2023
  8. eIGato commented on Mar 14, 2023

    @eIGato

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

  9. gvanrossum commented on Mar 14, 2023

    @gvanrossum
    Member

    3.12

  10. cretz commented on Nov 9, 2023

    @cretz

    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

Metadata

Metadata

Labels

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions