Skip to content

Commit 6424d0b

Browse files
authored
More logging for IPC failures in parallel checking (#20599)
1 parent c72d4f1 commit 6424d0b

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

mypy/build.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,22 +242,26 @@ def __init__(self, status_file: str, options_data: str, env: Mapping[str, str])
242242

243243
def connect(self) -> None:
244244
end_time = time.time() + WORKER_START_TIMEOUT
245+
last_exception: Exception | None = None
245246
while time.time() < end_time:
246247
try:
247248
data = read_status(self.status_file)
248-
except BadStatus:
249+
except BadStatus as exc:
250+
last_exception = exc
249251
time.sleep(WORKER_START_INTERVAL)
250252
continue
251253
try:
252254
pid, connection_name = data["pid"], data["connection_name"]
253-
assert isinstance(pid, int) and isinstance(connection_name, str)
255+
assert isinstance(pid, int), f"Bad PID: {pid}"
256+
assert isinstance(connection_name, str), f"Bad connection name: {connection_name}"
254257
# Double-check this status file is created by us.
255-
assert pid == self.proc.pid
258+
assert pid == self.proc.pid, f"PID mismatch: {pid} vs {self.proc.pid}"
256259
self.conn = IPCClient(connection_name, WORKER_CONNECTION_TIMEOUT)
257260
return
258-
except Exception:
261+
except Exception as exc:
262+
last_exception = exc
259263
break
260-
print("Failed to establish connection with worker")
264+
print("Failed to establish connection with worker:", last_exception)
261265
sys.exit(2)
262266

263267
def close(self) -> None:

mypy/build_worker/worker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ def main(argv: list[str]) -> None:
9292
try:
9393
with server:
9494
serve(server, ctx)
95-
except OSError:
96-
pass
95+
except OSError as exc:
96+
if options.verbosity >= 1:
97+
print("Error communicating with coordinator:", exc)
9798
except Exception as exc:
9899
report_internal_error(exc, errors.file, 0, errors, options)
99100
finally:

mypy/ipc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def read_status(status_file: str) -> dict[str, object]:
350350
except Exception as e:
351351
raise BadStatus("Malformed status file (not JSON)") from e
352352
if not isinstance(data, dict):
353-
raise BadStatus("Invalid status file (not a dict)")
353+
raise BadStatus(f"Invalid status file (not a dict): {data}")
354354
return data
355355

356356

0 commit comments

Comments
 (0)