mirror of
https://github.com/python/cpython.git
synced 2025-10-01 21:02:15 +00:00
[3.11] Refer to TimeoutError
instead of asyncio.TimeoutError
in asyncio-task.rst
(GH-106136) (#106180)
Co-authored-by: lightdrk <108566237+lightdrk@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
parent
9cc0533459
commit
2cce465416
1 changed files with 4 additions and 4 deletions
|
@ -601,16 +601,16 @@ Timeouts
|
||||||
If ``long_running_task`` takes more than 10 seconds to complete,
|
If ``long_running_task`` takes more than 10 seconds to complete,
|
||||||
the context manager will cancel the current task and handle
|
the context manager will cancel the current task and handle
|
||||||
the resulting :exc:`asyncio.CancelledError` internally, transforming it
|
the resulting :exc:`asyncio.CancelledError` internally, transforming it
|
||||||
into an :exc:`asyncio.TimeoutError` which can be caught and handled.
|
into a :exc:`TimeoutError` which can be caught and handled.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
The :func:`asyncio.timeout` context manager is what transforms
|
The :func:`asyncio.timeout` context manager is what transforms
|
||||||
the :exc:`asyncio.CancelledError` into an :exc:`asyncio.TimeoutError`,
|
the :exc:`asyncio.CancelledError` into a :exc:`TimeoutError`,
|
||||||
which means the :exc:`asyncio.TimeoutError` can only be caught
|
which means the :exc:`TimeoutError` can only be caught
|
||||||
*outside* of the context manager.
|
*outside* of the context manager.
|
||||||
|
|
||||||
Example of catching :exc:`asyncio.TimeoutError`::
|
Example of catching :exc:`TimeoutError`::
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue