Avoid reference loops in DependencyTaskGroup
Holding a reference to a traceback in a local variable can cause a reference loop (since the stack frame containing the local variable is inevitably referenced by the traceback), with the result that basically everything may need to get garbage collected. Prevent this by explicitly deleting the local variable holding the deletingtraceback once it is no longer required. Change-Id: Icde3dc0c6d5b2c799df778d3e1780514bc04bf5b
This commit is contained in:
parent
a56ec8be94
commit
2897634814
|
@ -401,11 +401,14 @@ class DependencyTaskGroup(object):
|
|||
self.cancel_all()
|
||||
|
||||
if raised_exceptions:
|
||||
if self.aggregate_exceptions:
|
||||
raise ExceptionGroup(v for t, v, tb in raised_exceptions)
|
||||
else:
|
||||
exc_type, exc_val, traceback = raised_exceptions[0]
|
||||
raise_(exc_type, exc_val, traceback)
|
||||
try:
|
||||
if self.aggregate_exceptions:
|
||||
raise ExceptionGroup(v for t, v, tb in raised_exceptions)
|
||||
else:
|
||||
exc_type, exc_val, traceback = raised_exceptions[0]
|
||||
raise_(exc_type, exc_val, traceback)
|
||||
finally:
|
||||
del raised_exceptions
|
||||
|
||||
def cancel_all(self, grace_period=None):
|
||||
for r in six.itervalues(self._runners):
|
||||
|
|
Loading…
Reference in New Issue