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

Class Timer

Lib/test/test_sched.py:13–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11
12
13class Timer:
14 def __init__(self):
15 self._cond = threading.Condition()
16 self._time = 0
17 self._stop = 0
18
19 def time(self):
20 with self._cond:
21 return self._time
22
23 # increase the time but not beyond the established limit
24 def sleep(self, t):
25 assert t >= 0
26 with self._cond:
27 t += self._time
28 while self._stop < t:
29 self._time = self._stop
30 self._cond.wait()
31 self._time = t
32
33 # advance time limit for user code
34 def advance(self, t):
35 assert t >= 0
36 with self._cond:
37 self._stop += t
38 self._cond.notify_all()
39
40
41class TestCase(unittest.TestCase):

Callers 2

test_enter_concurrentMethod · 0.70

Calls

no outgoing calls

Tested by 2

test_enter_concurrentMethod · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…