File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -843,17 +843,13 @@ Timeouts
843843 Wait for the *fut * :ref: `awaitable <asyncio-awaitables >`
844844 to complete with a timeout.
845845
846- If *fut * is a coroutine it is automatically scheduled as a Task.
847-
848846 *timeout * can either be ``None `` or a float or int number of seconds
849847 to wait for. If *timeout * is ``None ``, block until the future
850848 completes.
851849
852- If a timeout occurs, it cancels the task and raises
853- :exc: `TimeoutError `.
850+ If a timeout occurs, it cancels *fut * and raises :exc: `TimeoutError `.
854851
855- To avoid the task :meth: `cancellation <Task.cancel> `,
856- wrap it in :func: `shield `.
852+ To prevent *fut * from being cancelled, wrap it in :func: `shield `.
857853
858854 The function will wait until the future is actually cancelled,
859855 so the total wait time may exceed the *timeout *. If an exception
@@ -894,6 +890,10 @@ Timeouts
894890 .. versionchanged :: 3.11
895891 Raises :exc: `TimeoutError ` instead of :exc: `asyncio.TimeoutError `.
896892
893+ .. versionchanged :: 3.12
894+ Implemented using :func: `asyncio.timeout `, a coroutine passed as *fut *
895+ is no longer wrapped in a :class: `Task ` when *timeout * is positive.
896+
897897
898898Waiting primitives
899899==================
Original file line number Diff line number Diff line change @@ -440,15 +440,13 @@ def _release_waiter(waiter, *args):
440440async def wait_for (fut , timeout ):
441441 """Wait for the single Future or coroutine to complete, with timeout.
442442
443- Coroutine will be wrapped in Task.
444-
445443 Returns result of the Future or coroutine. When a timeout occurs,
446- it cancels the task and raises TimeoutError. To avoid the task
447- cancellation , wrap it in shield().
444+ it cancels fut and raises TimeoutError. To prevent fut from being
445+ cancelled , wrap it in shield().
448446
449- If the wait is cancelled, the task is also cancelled.
447+ If the wait is cancelled, fut is also cancelled.
450448
451- If the task suppresses the cancellation and returns a value instead,
449+ If fut suppresses the cancellation and returns a value instead,
452450 that value is returned.
453451
454452 This function is a coroutine.
You can’t perform that action at this time.
0 commit comments