mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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 594c369949
)
Co-authored-by: Guido van Rossum <guido@python.org>
This commit is contained in:
parent
aed28b7feb
commit
7fe949e5ea
4 changed files with 27 additions and 4 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue