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

pull/8055/head
Peter Hinch 2020-04-11 15:52:01 +01:00 zatwierdzone przez Damien George
rodzic 23a150789d
commit d94ac4333f
1 zmienionych plików z 7 dodań i 4 usunięć

Wyświetl plik

@ -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
-----------