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

Function wait

Lib/asyncio/tasks.py:405–432  ·  view source on GitHub ↗

Wait for the Futures or Tasks given by fs to complete. The fs iterable must not be empty. Returns two sets of Future: (done, pending). Usage: done, pending = await asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occu

(fs, *, timeout=None, return_when=ALL_COMPLETED)

Source from the content-addressed store, hash-verified

403
404
405async def wait(fs, *, timeout=None, return_when=ALL_COMPLETED):
406 """Wait for the Futures or Tasks given by fs to complete.
407
408 The fs iterable must not be empty.
409
410 Returns two sets of Future: (done, pending).
411
412 Usage:
413
414 done, pending = await asyncio.wait(fs)
415
416 Note: This does not raise TimeoutError! Futures that aren't done
417 when the timeout occurs are returned in the second set.
418 """
419 if futures.isfuture(fs) or coroutines.iscoroutine(fs):
420 raise TypeError(f"expect a list of futures, not {type(fs).__name__}")
421 if not fs:
422 raise ValueError('Set of Tasks/Futures is empty.')
423 if return_when not in (FIRST_COMPLETED, FIRST_EXCEPTION, ALL_COMPLETED):
424 raise ValueError(f'Invalid return_when value: {return_when}')
425
426 fs = set(fs)
427
428 if any(coroutines.iscoroutine(f) for f in fs):
429 raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
430
431 loop = events.get_running_loop()
432 return await _wait(fs, timeout, return_when, loop)
433
434
435def _release_waiter(waiter, *args):

Callers 4

fMethod · 0.50
test_reprMethod · 0.50
test_timeout_roundingMethod · 0.50

Calls 3

setFunction · 0.85
_waitFunction · 0.70
anyFunction · 0.50

Tested by 4

fMethod · 0.40
test_reprMethod · 0.40
test_timeout_roundingMethod · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…