Browse Source

docs/library/uasyncio.rst: Detail exception behaviour in cancel/timeout.

pull/8055/head
Peter Hinch 5 years ago
committed by Damien George
parent
commit
d94ac4333f
  1. 11
      docs/library/uasyncio.rst

11
docs/library/uasyncio.rst

@ -68,11 +68,13 @@ Additional functions
.. function:: wait_for(awaitable, timeout)
Wait for the *awaitable* to complete, but cancel it if it takes longer
that *timeout* seconds. If *awaitable* is not a task then a task will be
than *timeout* seconds. If *awaitable* is not a task then a task will be
created from it.
If a timeout occurs, it cancels the task and raises ``asyncio.TimeoutError``:
this should be trapped by the caller.
this should be trapped by the caller. The task receives
``asyncio.CancelledError`` which may be ignored or trapped using ``try...except``
or ``try...finally`` to run cleanup code.
Returns the return value of *awaitable*.
@ -106,8 +108,9 @@ class Task
.. method:: Task.cancel()
Cancel the task by injecting a ``CancelledError`` into it. The task may
or may not ignore this exception.
Cancel the task by injecting ``asyncio.CancelledError`` into it. The task may
ignore this exception. Cleanup code may be run by trapping it, or via
``try ... finally``.
class Event
-----------

Loading…
Cancel
Save