PyDocs

Nav

Networking and Interprocess Communication

wait_for

asyncio

async function (source) not WASI
  • wait_for(aw, timeout)
Wait for the single Future or coroutine to complete, with timeout.

Returns result of the Future or coroutine.  When a timeout occurs,
it cancels fut and raises TimeoutError.  To prevent fut from being
cancelled, wrap it in shield().

If the wait is cancelled, fut is also cancelled.

If fut suppresses the cancellation and returns a value instead,
that value is returned.

This function is a coroutine.
Changed in 3.7, 3.10, 3.11, 3.12
  • 3.7: When aw is cancelled due to a timeout, wait_for waits for aw to be cancelled. Previously, it raised TimeoutError immediately.
  • 3.10: Removed the loop parameter.
  • 3.11: Raises TimeoutError instead of asyncio.TimeoutError.
  • 3.12: Implemented using asyncio.timeout(), a coroutine passed as aw is no longer wrapped in a Task when timeout is positive.
0 Examples
No examples for asyncio/wait_for.
See Also
No see-alsos for asyncio/wait_for
0 Notes
No notes for wait_for