Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncio.TaskGroup keeps references to errors after raising ExceptionGroup #98543

Closed
kumaraditya303 opened this issue Oct 22, 2022 · 1 comment
Assignees
Labels
3.11 only security fixes 3.12 bugs and security fixes topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@kumaraditya303
Copy link
Contributor

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

@kumaraditya303 kumaraditya303 added type-bug An unexpected behavior, bug, or error topic-asyncio 3.11 only security fixes 3.12 bugs and security fixes labels Oct 22, 2022
gvanrossum pushed a commit that referenced this issue Oct 22, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 22, 2022
…rs after raising ExceptionGroup (pythonGH-98544)

(cherry picked from commit f4a1494)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
@kumaraditya303
Copy link
Contributor Author

Fixed by #98544

gvanrossum pushed a commit that referenced this issue Oct 24, 2022
…ors after raising ExceptionGroup (GH-98544) (#98550)

GH-98543: Fix `asyncio.TaskGroup`  to not keep reference to errors after raising ExceptionGroup  (GH-98544)
(cherry picked from commit f4a1494)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 bugs and security fixes topic-asyncio type-bug An unexpected behavior, bug, or error
Projects
Status: Done
Development

No branches or pull requests

3 participants
@gvanrossum @kumaraditya303 and others