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)
| 403 | |
| 404 | |
| 405 | async 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 | |
| 435 | def _release_waiter(waiter, *args): |
searching dependent graphs…