mirror of
https://github.com/python/cpython.git
synced 2025-10-07 15:42:02 +00:00
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>
This commit is contained in:
parent
4261b6bffc
commit
594c369949
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