diff options
author | themylogin <themylogin@gmail.com> | 2022-05-02 20:24:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-02 20:24:39 (GMT) |
commit | 9c204b148fad9742ed19b3bce173073cdec79819 (patch) | |
tree | 1be1a2b9f6c7fb8317c2c5a183bd5bdde8506b53 /Lib/concurrent | |
parent | c96da83a8ed020c026c3f080e0b646f553524c85 (diff) | |
download | cpython-9c204b148fad9742ed19b3bce173073cdec79819.zip cpython-9c204b148fad9742ed19b3bce173073cdec79819.tar.gz cpython-9c204b148fad9742ed19b3bce173073cdec79819.tar.bz2 |
bpo-46787: Fix `ProcessPoolExecutor exception` memory leak (GH-31408) (#31408)
Do not store `ProcessPoolExecutor` work item exception traceback that prevents
exception frame locals from being garbage collected.
Diffstat (limited to 'Lib/concurrent')
-rw-r--r-- | Lib/concurrent/futures/process.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py index 695f773..0d49379c 100644 --- a/Lib/concurrent/futures/process.py +++ b/Lib/concurrent/futures/process.py @@ -125,6 +125,9 @@ class _ExceptionWithTraceback: def __init__(self, exc, tb): tb = ''.join(format_exception(type(exc), exc, 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) |