gh-106558: Fix multiprocessing manager exception ref cycle.#106559
Merged
iritkatriel merged 9 commits intopython:mainfrom Aug 11, 2023
pteromys:fix-issue-106558
Merged
gh-106558: Fix multiprocessing manager exception ref cycle.#106559iritkatriel merged 9 commits intopython:mainfrom pteromys:fix-issue-106558
iritkatriel merged 9 commits intopython:mainfrom
pteromys:fix-issue-106558
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.
iritkatriel
reviewed
Jul 16, 2023
Misc/NEWS.d/next/Library/2023-07-09-00-36-33.gh-issue-106558.Zqsj6F.rst
Outdated
Show resolved
Hide resolved
iritkatriel
reviewed
Jul 16, 2023
Misc/NEWS.d/next/Library/2023-07-09-00-36-33.gh-issue-106558.Zqsj6F.rst
Outdated
Show resolved
Hide resolved
Member
|
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 <1055913+iritkatriel@users.noreply.github.com>
Member
|
Can you add a unit test based on your example from the issue? |
iritkatriel
reviewed
Aug 10, 2023
Member
iritkatriel
left a comment
There was a problem hiding this comment.
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.
iritkatriel
reviewed
Aug 10, 2023
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
iritkatriel
approved these changes
Aug 11, 2023
Contributor
|
Closing and re-opening to retrigger CLA checks. Sorry for the noise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If
kind == '#ERROR', thenresultis an exception whose attached traceback includes the frame that callsconvert_to_error()and hasresultin scope. So deleteresultfrom 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.handleErroruses and the docs for theexcept E as Nsyntax hint at.)Closes #106558.