MCPcopy Index your code
hub / github.com/python/cpython / result_iterator

Method result_iterator

Lib/concurrent/futures/_base.py:653–671  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

651 # Yield must be hidden in closure so that the futures are submitted
652 # before the first iterator value is required.
653 def result_iterator():
654 try:
655 # reverse to keep finishing order
656 fs.reverse()
657 while fs:
658 if (
659 buffersize
660 and (executor := executor_weakref())
661 and (args := next(zipped_iterables, None))
662 ):
663 fs.appendleft(executor.submit(fn, *args))
664 # Careful not to keep a reference to the popped future
665 if timeout is None:
666 yield _result_or_cancel(fs.pop())
667 else:
668 yield _result_or_cancel(fs.pop(), end_time - time.monotonic())
669 finally:
670 for future in fs:
671 future.cancel()
672 return result_iterator()
673
674 def shutdown(self, wait=True, *, cancel_futures=False):

Callers

nothing calls this directly

Calls 5

_result_or_cancelFunction · 0.85
reverseMethod · 0.45
submitMethod · 0.45
popMethod · 0.45
cancelMethod · 0.45

Tested by

no test coverage detected