File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -840,17 +840,13 @@ Timeouts
840840 Wait for the *aw * :ref: `awaitable <asyncio-awaitables >`
841841 to complete with a timeout.
842842
843- If *aw * is a coroutine it is automatically scheduled as a Task.
844-
845843 *timeout * can either be ``None `` or a float or int number of seconds
846844 to wait for. If *timeout * is ``None ``, block until the future
847845 completes.
848846
849- If a timeout occurs, it cancels the task and raises
850- :exc: `TimeoutError `.
847+ If a timeout occurs, it cancels *aw * and raises :exc: `TimeoutError `.
851848
852- To avoid the task :meth: `cancellation <Task.cancel> `,
853- wrap it in :func: `shield `.
849+ To prevent *aw * from being cancelled, wrap it in :func: `shield `.
854850
855851 The function will wait until the future is actually cancelled,
856852 so the total wait time may exceed the *timeout *. If an exception
@@ -891,6 +887,10 @@ Timeouts
891887 .. versionchanged :: 3.11
892888 Raises :exc: `TimeoutError ` instead of :exc: `asyncio.TimeoutError `.
893889
890+ .. versionchanged :: 3.12
891+ Implemented using :func: `asyncio.timeout `, a coroutine passed as *aw *
892+ is no longer wrapped in a :class: `Task ` when *timeout * is positive.
893+
894894
895895Waiting primitives
896896==================
Original file line number Diff line number Diff line change @@ -459,15 +459,13 @@ def _release_waiter(waiter, *args):
459459async def wait_for (fut , timeout ):
460460 """Wait for the single Future or coroutine to complete, with timeout.
461461
462- Coroutine will be wrapped in Task.
463-
464462 Returns result of the Future or coroutine. When a timeout occurs,
465- it cancels the task and raises TimeoutError. To avoid the task
466- cancellation , wrap it in shield().
463+ it cancels fut and raises TimeoutError. To prevent fut from being
464+ cancelled , wrap it in shield().
467465
468- If the wait is cancelled, the task is also cancelled.
466+ If the wait is cancelled, fut is also cancelled.
469467
470- If the task suppresses the cancellation and returns a value instead,
468+ If fut suppresses the cancellation and returns a value instead,
471469 that value is returned.
472470
473471 This function is a coroutine.
You can’t perform that action at this time.
0 commit comments