mirror of
https://github.com/python/cpython.git
synced 2025-10-02 21:25:24 +00:00
gh-102810 Improve the sphinx docs for asyncio.Timeout
(GH-102934)
(cherry picked from commit f13fdacadf
)
Co-authored-by: JosephSBoyle <48555120+JosephSBoyle@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
6ffeeb2199
commit
84ae50c914
1 changed files with 9 additions and 15 deletions
|
@ -624,32 +624,26 @@ Timeouts
|
||||||
The context manager produced by :func:`asyncio.timeout` can be
|
The context manager produced by :func:`asyncio.timeout` can be
|
||||||
rescheduled to a different deadline and inspected.
|
rescheduled to a different deadline and inspected.
|
||||||
|
|
||||||
.. class:: Timeout()
|
.. class:: Timeout(when)
|
||||||
|
|
||||||
An :ref:`asynchronous context manager <async-context-managers>`
|
An :ref:`asynchronous context manager <async-context-managers>`
|
||||||
that limits time spent inside of it.
|
for cancelling overdue coroutines.
|
||||||
|
|
||||||
.. versionadded:: 3.11
|
``when`` should be an absolute time at which the context should time out,
|
||||||
|
as measured by the event loop's clock:
|
||||||
|
|
||||||
|
- If ``when`` is ``None``, the timeout will never trigger.
|
||||||
|
- If ``when < loop.time()``, the timeout will trigger on the next
|
||||||
|
iteration of the event loop.
|
||||||
|
|
||||||
.. method:: when() -> float | None
|
.. method:: when() -> float | None
|
||||||
|
|
||||||
Return the current deadline, or ``None`` if the current
|
Return the current deadline, or ``None`` if the current
|
||||||
deadline is not set.
|
deadline is not set.
|
||||||
|
|
||||||
The deadline is a float, consistent with the time returned by
|
|
||||||
:meth:`loop.time`.
|
|
||||||
|
|
||||||
.. method:: reschedule(when: float | None)
|
.. method:: reschedule(when: float | None)
|
||||||
|
|
||||||
Change the time the timeout will trigger.
|
Reschedule the timeout.
|
||||||
|
|
||||||
If *when* is ``None``, any current deadline will be removed, and the
|
|
||||||
context manager will wait indefinitely.
|
|
||||||
|
|
||||||
If *when* is a float, it is set as the new deadline.
|
|
||||||
|
|
||||||
if *when* is in the past, the timeout will trigger on the next
|
|
||||||
iteration of the event loop.
|
|
||||||
|
|
||||||
.. method:: expired() -> bool
|
.. method:: expired() -> bool
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue