Skip to content

Commit d50dabd

Browse files
committed
move the ref cycle break into the finally block
1 parent f509097 commit d50dabd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Lib/concurrent/futures/_base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,11 +633,12 @@ def result_iterator():
633633

634634
# yield the awaited result
635635
yield fs.pop()._result
636-
except:
637-
# break the reference cycle with fs[-1]._exception's traceback
638-
fs.pop().cancel()
639-
raise
636+
640637
finally:
638+
# break the reference cycle with fs[-1]._exception's traceback
639+
if fs:
640+
fs.pop().cancel()
641+
641642
for future in fs:
642643
future.cancel()
643644

0 commit comments

Comments
 (0)