MCPcopy Index your code
hub / github.com/python/mypy / connect

Method connect

mypy/build.py:288–312  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

286 self.connected = False
287
288 def connect(self) -> None:
289 end_time = time.time() + WORKER_START_TIMEOUT
290 last_exception: Exception | None = None
291 while time.time() < end_time:
292 try:
293 data = read_status(self.status_file)
294 except BadStatus as exc:
295 last_exception = exc
296 time.sleep(WORKER_START_INTERVAL)
297 continue
298 try:
299 pid, connection_name = data["pid"], data["connection_name"]
300 assert isinstance(pid, int), f"Bad PID: {pid}"
301 assert isinstance(connection_name, str), f"Bad connection name: {connection_name}"
302 if sys.platform != "win32":
303 # Windows uses "wrapper processes" to run Python, so we cannot
304 # verify PIDs reliably.
305 assert pid == self.proc.pid, f"PID mismatch: {pid} vs {self.proc.pid}"
306 self.conn = IPCClient(connection_name, WORKER_CONNECTION_TIMEOUT)
307 self.connected = True
308 return
309 except Exception as exc:
310 last_exception = exc
311 break
312 print(f"Failed to establish connection with worker: {last_exception}")
313
314 def close(self) -> None:
315 if self.connected:

Callers 3

connectFunction · 0.80
__init__Method · 0.80
connect_dbFunction · 0.80

Calls 4

read_statusFunction · 0.90
IPCClientClass · 0.90
isinstanceFunction · 0.85
printFunction · 0.85

Tested by

no test coverage detected