8000 `asyncio.TaskGroup` keeps references to errors after raising ExceptionGroup · Issue #98543 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
asyncio.TaskGroup keeps references to errors after raising ExceptionGroup #98543
Closed
@kumaraditya303

Description

@kumaraditya303

asyncio.TaskGroup keeps references to errors after raising ExceptionGroup. This is because it keeps a ref to list of errors in errors local and since this local is kept alive by frame via traceback, this causes ref cycles. The correct fix is to use self._errors directly and then assign None to it in finally.

if self._errors:
# Exceptions are heavy objects that can have object
# cycles (bad for GC); let's not keep a reference to
# a bunch of them.
errors = self._errors
self._errors = None
me = BaseExceptionGroup('unhandled errors in a TaskGroup', errors)
raise me from None

Metadata

Metadata

Labels

3.11only security fixes3.12only security fixestopic-asynciotype-bugAn unexpected behavior, bug, or error

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0