-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-106558: Fix multiprocessing manager exception ref cycle. #106559
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
Conversation
If `kind == '#ERROR'`, then `result` is an exception whose attached traceback includes the frame that calls `convert_to_error()` and has `result` in scope. So delete `result` from the scope as we raise it, to save the consumer of these exceptions from having to cope with a buildup of cyclic references.
Misc/NEWS.d/next/Library/2023-07-09-00-36-33.gh-issue-106558.Zqsj6F.rst
Outdated
Show resolved
Hide resolved
Misc/NEWS.d/next/Library/2023-07-09-00-36-33.gh-issue-106558.Zqsj6F.rst
Outdated
Show resolved
Hide resolved
Yes, we need to do this sometimes with exceptions because the traceback cycles back to the exception through the frame locals sigh. |
Co-authored-by: Irit Katriel <[email protected]>
Can you add a unit test based on your example from the issue? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've confirmed that the test fails on main. Just a suggestion to move the comment into the class, so they stay together as things move around.
Closing and re-opening to retrigger CLA checks. Sorry for the noise. |
If
kind == '#ERROR'
, thenresult
is an exception whose attached traceback includes the frame that callsconvert_to_error()
and hasresult
in scope. So deleteresult
from the scope as we raise it, to save the consumer of these exceptions from having to cope with a buildup of cyclic references.(This is the same try/finally/del pattern that
logging.Handler.handleError
uses and the docs for theexcept E as N
syntax hint at.)Closes #106558.