Skip to content

Rename asyncio.Timeout to be unlike asyncio.timeout #141401

@xitop

Description

@xitop

Feature or enhancement

Proposal:

This renaming was proposed on Discourse as a solution for the annoyance that two very similar names exist and both can be used in the same statement without any error, because both are async context managers (CM):

async with asyncio.timeout(99): await ...  # timeout is using relative time as expected
async with asyncio.Timeout(99): await ...  # Timeout is using loop clock absolute time;
                                           # small values are already in the past,
                                           # so it cancels immediately

It is very easy to make an error and write the upper-case Timeout by mistake. For instance we already have the upper-case TaskGroup async CM.

Using timeout creates a Timeout object. Because Timeout is not intended to be used directly, giving it a new name and deprecating the old one was suggested in the linked Discourse thread.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/error-prone-naming-asyncio-timeout-vs-asyncio-timeout/104727

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-asynciotype-featureA feature request or enhancement

    Projects

    Status

    Done

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions