Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,26 @@ def __init__(self, status_file: str, options_data: str, env: Mapping[str, str])

def connect(self) -> None:
end_time = time.time() + WORKER_START_TIMEOUT
last_exception: Exception | None = None
while time.time() < end_time:
try:
data = read_status(self.status_file)
except BadStatus:
except BadStatus as exc:
last_exception = exc
time.sleep(WORKER_START_INTERVAL)
continue
try:
pid, connection_name = data["pid"], data["connection_name"]
assert isinstance(pid, int) and isinstance(connection_name, str)
assert isinstance(pid, int), f"Bad PID: {pid}"
assert isinstance(connection_name, str), f"Bad connection name: {connection_name}"
# Double-check this status file is created by us.
assert pid == self.proc.pid
assert pid == self.proc.pid, f"PID mismatch: {pid} vs {self.proc.pid}"
self.conn = IPCClient(connection_name, WORKER_CONNECTION_TIMEOUT)
return
except Exception:
except Exception as exc:
last_exception = exc
break
print("Failed to establish connection with worker")
print("Failed to establish connection with worker:", last_exception)
sys.exit(2)

def close(self) -> None:
Expand Down
5 changes: 3 additions & 2 deletions mypy/build_worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ def main(argv: list[str]) -> None:
try:
with server:
serve(server, ctx)
except OSError:
pass
except OSError as exc:
if options.verbosity >= 1:
print("Error communicating with coordinator:", exc)
except Exception as exc:
report_internal_error(exc, errors.file, 0, errors, options)
finally:
Expand Down
2 changes: 1 addition & 1 deletion mypy/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def read_status(status_file: str) -> dict[str, object]:
except Exception as e:
raise BadStatus("Malformed status file (not JSON)") from e
if not isinstance(data, dict):
raise BadStatus("Invalid status file (not a dict)")
raise BadStatus(f"Invalid status file (not a dict): {data}")
return data


Expand Down