summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorJosephSBoyle <48555120+JosephSBoyle@users.noreply.github.com>2023-03-19 20:06:09 (GMT)
committerGitHub <noreply@github.com>2023-03-19 20:06:09 (GMT)
commit699cb20ae6fdef8b0f13d633cf4858465ef3469f (patch)
treeec8b7d27456a2e32282a0c32f8684fc95d5843f4 /Lib/asyncio
parentd51a6dc28e1b2cd0353a78bd13f46e288fa39aa6 (diff)
downloadcpython-699cb20ae6fdef8b0f13d633cf4858465ef3469f.zip
cpython-699cb20ae6fdef8b0f13d633cf4858465ef3469f.tar.gz
cpython-699cb20ae6fdef8b0f13d633cf4858465ef3469f.tar.bz2
gh-102810: Add docstrings to the public-facing methods of `asyncio.Timeout` (#102811)
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/timeouts.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/asyncio/timeouts.py b/Lib/asyncio/timeouts.py
index 94d2553..d07b291 100644
--- a/Lib/asyncio/timeouts.py
+++ b/Lib/asyncio/timeouts.py
@@ -25,8 +25,18 @@ class _State(enum.Enum):
@final
class Timeout:
+ """Asynchronous context manager for cancelling overdue coroutines.
+
+ Use `timeout()` or `timeout_at()` rather than instantiating this class directly.
+ """
def __init__(self, when: Optional[float]) -> None:
+ """Schedule a timeout that will trigger at a given loop time.
+
+ - 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.
+ """
self._state = _State.CREATED
self._timeout_handler: Optional[events.TimerHandle] = None
@@ -34,9 +44,11 @@ class Timeout:
self._when = when
def when(self) -> Optional[float]:
+ """Return the current deadline."""
return self._when
def reschedule(self, when: Optional[float]) -> None:
+ """Reschedule the timeout."""
assert self._state is not _State.CREATED
if self._state is not _State.ENTERED:
raise RuntimeError(