]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.11] gh-111085: Fix invalid state handling in TaskGroup and Timeout (GH-111111...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 21 Oct 2023 19:40:07 +0000 (21:40 +0200)
committerGitHub <noreply@github.com>
Sat, 21 Oct 2023 19:40:07 +0000 (19:40 +0000)
commitcf777399a93f837bca623e8cf887fc0ec42340e6
tree29540861be7da307478a9e802fc8107d172e24d5
parentcf28c61c73174638b7596d9fff70f3c4e4965b30
[3.11] gh-111085: Fix invalid state handling in TaskGroup and Timeout (GH-111111) (GH-111172)

asyncio.TaskGroup and asyncio.Timeout classes now raise proper RuntimeError
if they are improperly used.

* When they are used without entering the context manager.
* When they are used after finishing.
* When the context manager is entered more than once (simultaneously or
  sequentially).
* If there is no current task when entering the context manager.

They now remain in a consistent state after an exception is thrown,
so subsequent operations can be performed correctly (if they are allowed).

(cherry picked from commit 6c23635f2b7067ef091a550954e09f8b7c329e3f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: James Hilton-Balfe <gobot1234yt@gmail.com>
Lib/asyncio/taskgroups.py
Lib/asyncio/timeouts.py
Lib/test/test_asyncio/test_taskgroups.py
Lib/test/test_asyncio/test_timeouts.py
Lib/test/test_asyncio/utils.py
Misc/NEWS.d/next/Library/2023-10-20-15-29-10.gh-issue-110910.u2oPwX.rst [new file with mode: 0644]