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

Function _yield_finished_futures

Lib/concurrent/futures/_base.py:171–190  ·  view source on GitHub ↗

Iterate on the list *fs*, yielding finished futures one by one in reverse order. Before yielding a future, *waiter* is removed from its waiters and the future is removed from each set in the collection of sets *ref_collect*. The aim of this function is to avoid keeping stal

(fs, waiter, ref_collect)

Source from the content-addressed store, hash-verified

169
170
171def _yield_finished_futures(fs, waiter, ref_collect):
172 """
173 Iterate on the list *fs*, yielding finished futures one by one in
174 reverse order.
175 Before yielding a future, *waiter* is removed from its waiters
176 and the future is removed from each set in the collection of sets
177 *ref_collect*.
178
179 The aim of this function is to avoid keeping stale references after
180 the future is yielded and before the iterator resumes.
181 """
182 while fs:
183 f = fs[-1]
184 for futures_set in ref_collect:
185 futures_set.remove(f)
186 with f._condition:
187 f._waiters.remove(waiter)
188 del f
189 # Careful not to keep a reference to the popped value
190 yield fs.pop()
191
192
193def as_completed(fs, timeout=None):

Callers 1

as_completedFunction · 0.85

Calls 2

removeMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…