@@ -922,6 +922,48 @@ Task functions
922922 except CancelledError:
923923 res = None
924924
925+ .. function :: wait(fs, \*, loop=None, timeout=None, return_when=ALL_COMPLETED)
926+
927+ Wait for the Futures and coroutines given by fs to complete. Coroutines will
928+ be wrapped in Tasks. Returns two sets of
929+ :class: `~concurrent.futures.Future `: (done, pending).
930+
931+ *timeout * can be used to control the maximum number of seconds to wait before
932+ returning. *timeout * can be an int or float. If *timeout * is not specified
933+ or ``None ``, there is no limit to the wait time.
934+
935+ *return_when * indicates when this function should return. It must be one of
936+ the following constants of the :mod`concurrent.futures` module:
937+
938+ .. tabularcolumns :: |l|L|
939+
940+ +-----------------------------+----------------------------------------+
941+ | Constant | Description |
942+ +=============================+========================================+
943+ | :const: `FIRST_COMPLETED ` | The function will return when any |
944+ | | future finishes or is cancelled. |
945+ +-----------------------------+----------------------------------------+
946+ | :const: `FIRST_EXCEPTION ` | The function will return when any |
947+ | | future finishes by raising an |
948+ | | exception. If no future raises an |
949+ | | exception then it is equivalent to |
950+ | | :const: `ALL_COMPLETED `. |
951+ +-----------------------------+----------------------------------------+
952+ | :const: `ALL_COMPLETED ` | The function will return when all |
953+ | | futures finish or are cancelled. |
954+ +-----------------------------+----------------------------------------+
955+
956+ This function returns a :ref: `coroutine <coroutine >`.
957+
958+ Usage::
959+
960+ done, pending = yield from asyncio.wait(fs)
961+
962+ .. note ::
963+
964+ This does not raise :exc: `TimeoutError `! Futures that aren't done when
965+ the timeout occurs are returned in the second set.
966+
925967
926968Task
927969----
0 commit comments