Skip to content

Commit ab4182b

Browse files
committed
introduce current_timeout variable
1 parent 2a30697 commit ab4182b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Lib/concurrent/futures/_base.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,20 +628,21 @@ def result_iterator():
628628
try:
629629
# reverse to keep finishing order
630630
fs.reverse()
631+
current_timeout = timeout
631632
while fs:
632633
# Careful not to keep a reference to the popped future or its result
633-
if timeout is None:
634-
result.append(_result_or_cancel(fs.pop()))
635-
else:
636-
result.append(
637-
_result_or_cancel(fs.pop(), end_time - time.monotonic())
638-
)
634+
if current_timeout is not None:
635+
current_timeout = end_time - time.monotonic()
636+
637+
result.append(_result_or_cancel(fs.pop(), current_timeout))
638+
639639
if (
640640
buffersize
641641
and (executor := executor_weakref())
642642
and (args := next(zipped_iterables, None))
643643
):
644644
fs.appendleft(executor.submit(fn, *args))
645+
645646
yield result.pop()
646647
finally:
647648
for future in fs:

0 commit comments

Comments
 (0)