diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2022-03-17 20:51:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-17 20:51:40 (GMT) |
commit | 903f0a02c16240dc769a08c30e8d072a4fb09154 (patch) | |
tree | 00a9ff2477f94c7067c9daad481abde0d8d8ff3b /Doc | |
parent | 33698e8ff40fcc67df3d95658e87196f8021de6f (diff) | |
download | cpython-903f0a02c16240dc769a08c30e8d072a4fb09154.zip cpython-903f0a02c16240dc769a08c30e8d072a4fb09154.tar.gz cpython-903f0a02c16240dc769a08c30e8d072a4fb09154.tar.bz2 |
bpo-34790: Remove passing coroutine objects to asyncio.wait() (GH-31964)
Co-authored-by: Yury Selivanov <yury@edgedb.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/asyncio-task.rst | 46 |
1 files changed, 3 insertions, 43 deletions
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst index faf5910..294f5ab 100644 --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -534,7 +534,7 @@ Waiting Primitives .. coroutinefunction:: wait(aws, *, timeout=None, return_when=ALL_COMPLETED) - Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws* + Run :class:`~asyncio.Future` and :class:`~asyncio.Task` instances in the *aws* iterable concurrently and block until the condition specified by *return_when*. @@ -577,51 +577,11 @@ Waiting Primitives Unlike :func:`~asyncio.wait_for`, ``wait()`` does not cancel the futures when a timeout occurs. - .. deprecated:: 3.8 - - If any awaitable in *aws* is a coroutine, it is automatically - scheduled as a Task. Passing coroutines objects to - ``wait()`` directly is deprecated as it leads to - :ref:`confusing behavior <asyncio_example_wait_coroutine>`. - - .. versionchanged:: 3.10 - Removed the *loop* parameter. - - .. _asyncio_example_wait_coroutine: - .. note:: - - ``wait()`` schedules coroutines as Tasks automatically and later - returns those implicitly created Task objects in ``(done, pending)`` - sets. Therefore the following code won't work as expected:: - - async def foo(): - return 42 - - coro = foo() - done, pending = await asyncio.wait({coro}) - - if coro in done: - # This branch will never be run! - - Here is how the above snippet can be fixed:: - - async def foo(): - return 42 - - task = asyncio.create_task(foo()) - done, pending = await asyncio.wait({task}) - - if task in done: - # Everything will work as expected now. - - .. deprecated-removed:: 3.8 3.11 - - Passing coroutine objects to ``wait()`` directly is - deprecated. - .. versionchanged:: 3.10 Removed the *loop* parameter. + .. versionchanged:: 3.11 + Passing coroutine objects to ``wait()`` directly is forbidden. .. function:: as_completed(aws, *, timeout=None) |