Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 699cb20

Browse files
JosephSBoylegvanrossumAlexWaygood
authored
gh-102810: Add docstrings to the public-facing methods of asyncio.Timeout (#102811)
Co-authored-by: Guido van Rossum <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
1 parent d51a6dc commit 699cb20

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Lib/asyncio/timeouts.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,30 @@ class _State(enum.Enum):
2525

2626
@final
2727
class Timeout:
28+
"""Asynchronous context manager for cancelling overdue coroutines.
29+
30+
Use `timeout()` or `timeout_at()` rather than instantiating this class directly.
31+
"""
2832

2933
def __init__(self, when: Optional[float]) -> None:
34+
"""Schedule a timeout that will trigger at a given loop time.
35+
36+
- If `when` is `None`, the timeout will never trigger.
37+
- If `when < loop.time()`, the timeout will trigger on the next
38+
iteration of the event loop.
39+
"""
3040
self._state = _State.CREATED
3141

3242
self._timeout_handler: Optional[events.TimerHandle] = None
3343
self._task: Optional[tasks.Task] = None
3444
self._when = when
3545

3646
def when(self) -> Optional[float]:
47+
"""Return the current deadline."""
3748
return self._when
3849

3950
def reschedule(self, when: Optional[float]) -> None:
51+
"""Reschedule the timeout."""
4052
assert self._state is not _State.CREATED
4153
if self._state is not _State.ENTERED:
4254
raise RuntimeError(

0 commit comments

Comments
 (0)