MCPcopy Index your code
hub / github.com/python/cpython / reschedule

Method reschedule

Lib/asyncio/timeouts.py:48–69  ·  view source on GitHub ↗

Reschedule the timeout.

(self, when: float | None)

Source from the content-addressed store, hash-verified

46 return self._when
47
48 def reschedule(self, when: float | None) -> None:
49 """Reschedule the timeout."""
50 if self._state is not _State.ENTERED:
51 if self._state is _State.CREATED:
52 raise RuntimeError("Timeout has not been entered")
53 raise RuntimeError(
54 f"Cannot change state of {self._state.value} Timeout",
55 )
56
57 self._when = when
58
59 if self._timeout_handler is not None:
60 self._timeout_handler.cancel()
61
62 if when is None:
63 self._timeout_handler = None
64 else:
65 loop = events.get_running_loop()
66 if when <= loop.time():
67 self._timeout_handler = loop.call_soon(self._on_timeout)
68 else:
69 self._timeout_handler = loop.call_at(when, self._on_timeout)
70
71 def expired(self) -> bool:
72 """Is timeout expired during execution?"""

Callers 8

__aenter__Method · 0.95
coro_fnMethod · 0.80
test_rescheduleMethod · 0.80
test_timeout_finishedMethod · 0.80
test_timeout_expiredMethod · 0.80
test_timeout_expiringMethod · 0.80

Calls 4

cancelMethod · 0.45
timeMethod · 0.45
call_soonMethod · 0.45
call_atMethod · 0.45

Tested by 7

coro_fnMethod · 0.64
test_rescheduleMethod · 0.64
test_timeout_finishedMethod · 0.64
test_timeout_expiredMethod · 0.64
test_timeout_expiringMethod · 0.64