mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
gh-128552: fix refcycles in eager task creation (#128553)
(cherry picked from commit 61b9811ac6
)
This commit is contained in:
parent
7e099c51b6
commit
13835888e6
4 changed files with 72 additions and 6 deletions
|
@ -205,7 +205,12 @@ class TaskGroup:
|
|||
else:
|
||||
self._tasks.add(task)
|
||||
task.add_done_callback(self._on_task_done)
|
||||
return task
|
||||
try:
|
||||
return task
|
||||
finally:
|
||||
# gh-128552: prevent a refcycle of
|
||||
# task.exception().__traceback__->TaskGroup.create_task->task
|
||||
del task
|
||||
|
||||
# Since Python 3.8 Tasks propagate all exceptions correctly,
|
||||
# except for KeyboardInterrupt and SystemExit which are
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue