MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / _IpcChannel

Class _IpcChannel

pythonFiles/visualstudio_py_testlauncher.py:103–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101
102
103class _IpcChannel(object):
104 def __init__(self, socket, callback):
105 self.socket = socket
106 self.seq = 0
107 self.callback = callback
108 self.lock = thread.allocate_lock()
109 self._closed = False
110 # start the testing reader thread loop
111 self.test_thread_id = thread.start_new_thread(self.readSocket, ())
112
113 def close(self):
114 self._closed = True
115
116 def readSocket(self):
117 try:
118 self.socket.recv(1024)
119 self.callback()
120 except OSError:
121 if not self._closed:
122 raise
123
124 def receive(self):
125 pass
126
127 def send_event(self, name, **args):
128 with self.lock:
129 body = {"type": "event", "seq": self.seq, "event": name, "body": args}
130 self.seq += 1
131 content = json.dumps(body).encode("utf8")
132 headers = ("Content-Length: %d\n\n" % (len(content),)).encode("utf8")
133 self.socket.send(headers)
134 self.socket.send(content)
135
136
137_channel = None

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68