]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-111085: Fix invalid state handling in TaskGroup and Timeout (#111111)
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 21 Oct 2023 19:18:34 +0000 (22:18 +0300)
committerGitHub <noreply@github.com>
Sat, 21 Oct 2023 19:18:34 +0000 (22:18 +0300)
commit6c23635f2b7067ef091a550954e09f8b7c329e3f
treeb420a114d1b1ff9ca39f85b69ac68311d580ffe5
parentfd60549c0ac6c81f05594a5141d24b4433ae39be
gh-111085: Fix invalid state handling in TaskGroup and Timeout (#111111)

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).

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]