bpo-46787: Fix ProcessPoolExecutor exception memory leak (GH-31408) (GH-31408)

Do not store `ProcessPoolExecutor` work item exception traceback that prevents
exception frame locals from being garbage collected.
(cherry picked from commit 9c204b148f)

Co-authored-by: themylogin <themylogin@gmail.com>
This commit is contained in:
Miss Islington (bot) 2022-05-02 15:51:20 -07:00 committed by GitHub
parent 3fe4e4602d
commit 51b885a38a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -126,6 +126,9 @@ def __init__(self, exc, tb):
tb = traceback.format_exception(type(exc), exc, tb)
tb = ''.join(tb)
self.exc = exc
# Traceback object needs to be garbage-collected as its frames
# contain references to all the objects in the exception scope
self.exc.__traceback__ = None
self.tb = '\n"""\n%s"""' % tb
def __reduce__(self):
return _rebuild_exc, (self.exc, self.tb)