MCPcopy Create free account
hub / github.com/microsoft/debugpy / Timeline

Class Timeline

tests/timeline.py:26–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25
26class Timeline(object):
27 def __init__(self, name=None):
28 self.name = str(name if name is not None else id(self))
29 self.ignore_unobserved = []
30
31 self._listeners = [] # [(expectation, callable)]
32 self._index_iter = itertools.count(1)
33 self._accepting_new = threading.Event()
34 self._finalized = threading.Event()
35 self._recorded_new = threading.Condition()
36 self._record_queue = queue.Queue()
37
38 self._recorder_thread = threading.Thread(
39 target=self._recorder_worker, name=f"{self} recorder"
40 )
41 self._recorder_thread.daemon = True
42 self._recorder_thread.start()
43
44 # Set up initial environment for our first mark()
45 self._last = None
46 self._beginning = None
47 self._accepting_new.set()
48
49 self._beginning = self.mark("START")
50 assert self._last is self._beginning
51 self._proceeding_from = self._beginning
52
53 def expect_frozen(self):
54 if not self.is_frozen:
55 raise Exception("Timeline can only be inspected while frozen.")
56
57 def __iter__(self):
58 self.expect_frozen()
59 return self._beginning.and_following()
60
61 def __len__(self):
62 return len(self.history())
63
64 @property
65 def beginning(self):
66 return self._beginning
67
68 @property
69 def last(self):
70 self.expect_frozen()
71 return self._last
72
73 def history(self):
74 self.expect_frozen()
75 return list(iter(self))
76
77 def __contains__(self, expectation):
78 self.expect_frozen()
79 return any(expectation.test(self.beginning, self.last))
80
81 def all_occurrences_of(self, expectation):
82 return tuple(occ for occ in self if occ == expectation)
83

Callers 1

factoryFunction · 0.90

Calls

no outgoing calls

Tested by 1

factoryFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…