diff options
| author | JosephSBoyle <48555120+JosephSBoyle@users.noreply.github.com> | 2023-03-23 16:43:13 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-23 16:43:13 (GMT) |
| commit | f13fdacadfca87c71130057b6f03c89ae640c9b2 (patch) | |
| tree | 095f497d31956db34ee32b10fc1847fdbb1add7e | |
| parent | bf42eb8722befddf099a7bc26ea4a258179c32bf (diff) | |
| download | cpython-f13fdacadfca87c71130057b6f03c89ae640c9b2.zip cpython-f13fdacadfca87c71130057b6f03c89ae640c9b2.tar.gz cpython-f13fdacadfca87c71130057b6f03c89ae640c9b2.tar.bz2 | |
gh-102810 Improve the sphinx docs for `asyncio.Timeout` (#102934)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
| -rw-r--r-- | Doc/library/asyncio-task.rst | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst index d908e45..c5a480b 100644 --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -624,32 +624,26 @@ Timeouts The context manager produced by :func:`asyncio.timeout` can be rescheduled to a different deadline and inspected. - .. class:: Timeout() + .. class:: Timeout(when) 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 Return the current deadline, or ``None`` if the current deadline is not set. - The deadline is a float, consistent with the time returned by - :meth:`loop.time`. - .. method:: reschedule(when: float | None) - Change the time the timeout will trigger. - - 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. + Reschedule the timeout. .. method:: expired() -> bool |
