summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/taskgroups.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-06-30 18:02:42 (GMT)
committerGitHub <noreply@github.com>2022-06-30 18:02:42 (GMT)
commit7fe949e5eac3efa8bb0cd9e7274380a044a408ea (patch)
tree8f69cacdca1e35f2eccc48cbde6dfe7c1ffa5b1b /Lib/asyncio/taskgroups.py
parentaed28b7feb349cdeb45285d46ae7b36f200c957e (diff)
downloadcpython-7fe949e5eac3efa8bb0cd9e7274380a044a408ea.zip
cpython-7fe949e5eac3efa8bb0cd9e7274380a044a408ea.tar.gz
cpython-7fe949e5eac3efa8bb0cd9e7274380a044a408ea.tar.bz2
GH-94398: TaskGroup: Fail create_task() during shutdown (GH-94400) (GH-94463)
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> (cherry picked from commit 594c3699492bfb007650538726d953cbed55de04) Co-authored-by: Guido van Rossum <guido@python.org>
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: