Do not store `ProcessPoolExecutor` work item exception traceback that prevents
exception frame locals from being garbage collected.
(cherry picked from commit
9c204b148fad9742ed19b3bce173073cdec79819)
Co-authored-by: themylogin <themylogin@gmail.com>
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)
--- /dev/null
+Fix :class:`concurrent.futures.ProcessPoolExecutor` exception memory leak