summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/taskgroups.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2022-06-30 17:10:46 (GMT)
committerGitHub <noreply@github.com>2022-06-30 17:10:46 (GMT)
commit594c3699492bfb007650538726d953cbed55de04 (patch)
tree0c08bef359427752e98c566d436e5d3208b1b490 /Lib/asyncio/taskgroups.py
parent4261b6bffc0b8bb5c6d4d80578a81b7520f4aefc (diff)
downloadcpython-594c3699492bfb007650538726d953cbed55de04.zip
cpython-594c3699492bfb007650538726d953cbed55de04.tar.gz
cpython-594c3699492bfb007650538726d953cbed55de04.tar.bz2
GH-94398: TaskGroup: Fail create_task() during shutdown (GH-94400)
Once the task group is shutting down, it should not be possible to create a new task. Here "shutting down" means `self._aborting` is set, indicating that at least one task has failed and we have cancelled all others. Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/asyncio/taskgroups.py')
-rw-r--r--Lib/asyncio/taskgroups.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/asyncio/taskgroups.py b/Lib/asyncio/taskgroups.py
index 9e0610d..3ca6506 100644
--- a/Lib/asyncio/taskgroups.py
+++ b/Lib/asyncio/taskgroups.py
@@ -138,6 +138,8 @@ class TaskGroup:
raise RuntimeError(f"TaskGroup {self!r} has not been entered")
if self._exiting and not self._tasks:
raise RuntimeError(f"TaskGroup {self!r} is finished")
+ if self._aborting:
+ raise RuntimeError(f"TaskGroup {self!r} is shutting down")
if context is None:
task = self._loop.create_task(coro)
else: