File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -853,17 +853,13 @@ Timeouts
853853 Wait for the *aw * :ref: `awaitable <asyncio-awaitables >`
854854 to complete with a timeout.
855855
856- If *aw * is a coroutine it is automatically scheduled as a Task.
857-
858856 *timeout * can either be ``None `` or a float or int number of seconds
859857 to wait for. If *timeout * is ``None ``, block until the future
860858 completes.
861859
862- If a timeout occurs, it cancels the task and raises
863- :exc: `TimeoutError `.
860+ If a timeout occurs, it cancels *aw * and raises :exc: `TimeoutError `.
864861
865- To avoid the task :meth: `cancellation <Task.cancel> `,
866- wrap it in :func: `shield `.
862+ To prevent *aw * from being cancelled, wrap it in :func: `shield `.
867863
868864 The function will wait until the future is actually cancelled,
869865 so the total wait time may exceed the *timeout *. If an exception
@@ -904,6 +900,10 @@ Timeouts
904900 .. versionchanged :: 3.11
905901 Raises :exc: `TimeoutError ` instead of :exc: `asyncio.TimeoutError `.
906902
903+ .. versionchanged :: 3.12
904+ Implemented using :func: `asyncio.timeout `, a coroutine passed as *aw *
905+ is no longer wrapped in a :class: `Task ` when *timeout * is positive.
906+
907907
908908Waiting primitives
909909==================
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