File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -25,18 +25,30 @@ class _State(enum.Enum):
2525
2626@final
2727class 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 (
You can’t perform that action at this time.
0 commit comments