Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
introduce current_timeout variable
  • Loading branch information
ebonnal committed Mar 19, 2025
commit ab4182befdf3786fd3b011a32373a102786d972f
13 changes: 7 additions & 6 deletions Lib/concurrent/futures/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,20 +628,21 @@ def result_iterator():
try:
# reverse to keep finishing order
fs.reverse()
current_timeout = timeout
while fs:
# Careful not to keep a reference to the popped future or its result
if timeout is None:
result.append(_result_or_cancel(fs.pop()))
else:
result.append(
_result_or_cancel(fs.pop(), end_time - time.monotonic())
)
if current_timeout is not None:
current_timeout = end_time - time.monotonic()

result.append(_result_or_cancel(fs.pop(), current_timeout))

if (
buffersize
and (executor := executor_weakref())
and (args := next(zipped_iterables, None))
):
fs.appendleft(executor.submit(fn, *args))

yield result.pop()
finally:
for future in fs:
Expand Down
Loading