]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-46771: Implement asyncio context managers for handling timeouts (GH-31394)
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Thu, 10 Mar 2022 16:05:20 +0000 (18:05 +0200)
committerGitHub <noreply@github.com>
Thu, 10 Mar 2022 16:05:20 +0000 (08:05 -0800)
commitf537b2a4fb86445ee3bd6ca7f10bc9d3a9f37da5
treed67041f2121c19f1ba0a6a723a8aeccb771d3614
parent32bf3597922ac3f613989582afa2bff43bea8a2f
bpo-46771: Implement asyncio context managers for handling timeouts (GH-31394)

Example:

async with asyncio.timeout(5):
    await some_task()

Will interrupt the await and raise TimeoutError if some_task() takes longer than 5 seconds.

Co-authored-by: Guido van Rossum <guido@python.org>
Lib/asyncio/__init__.py
Lib/asyncio/timeouts.py [new file with mode: 0644]
Lib/test/test_asyncio/test_timeouts.py [new file with mode: 0644]
Misc/NEWS.d/next/Library/2022-02-21-11-41-23.bpo-464471.fL06TV.rst [new file with mode: 0644]