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

Method __init__

src/debugpy/adapter/components.py:34–58  ·  view source on GitHub ↗
(self, session, stream=None, channel=None)

Source from the content-addressed store, hash-verified

32 """
33
34 def __init__(self, session, stream=None, channel=None):
35 assert (stream is None) ^ (channel is None)
36
37 try:
38 lock_held = session.lock.acquire(blocking=False)
39 assert lock_held, "__init__ of a Component subclass must lock its Session"
40 finally:
41 session.lock.release()
42
43 super().__init__()
44
45 self.session = session
46
47 if channel is None:
48 stream.name = str(self)
49 channel = messaging.JsonMessageChannel(stream, self)
50 channel.start()
51 else:
52 channel.name = channel.stream.name = str(self)
53 channel.handlers = self
54 self.channel = channel
55 self.is_connected = True
56
57 # Do this last to avoid triggering useless notifications for assignments above.
58 self.observers += [lambda *_: self.session.notify_changed()]
59
60 def __str__(self):
61 return f"{type(self).__name__}[{self.session.id}]"

Callers 1

__init__Method · 0.45

Calls 2

startMethod · 0.95
notify_changedMethod · 0.80

Tested by

no test coverage detected