Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 9c204b1)

Co-authored-by: themylogin <themylogin@gmail.com>
  • Loading branch information
themylogin authored and miss-islington committed May 2, 2022
commit f5457e286a442b835b36291417424103c6fb9392
3 changes: 3 additions & 0 deletions Lib/concurrent/futures/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :class:`concurrent.futures.ProcessPoolExecutor` exception memory leak