@@ -283,6 +283,7 @@ def __init__(self, status_file: str, options_data: str, env: Mapping[str, str])
283283 ]
284284 # Return early without waiting, caller must call connect() before using the client.
285285 self .proc = subprocess .Popen (command , env = env )
286+ self .connected = False
286287
287288 def connect (self ) -> None :
288289 end_time = time .time () + WORKER_START_TIMEOUT
@@ -303,12 +304,12 @@ def connect(self) -> None:
303304 # verify PIDs reliably.
304305 assert pid == self .proc .pid , f"PID mismatch: { pid } vs { self .proc .pid } "
305306 self .conn = IPCClient (connection_name , WORKER_CONNECTION_TIMEOUT )
307+ self .connected = True
306308 return
307309 except Exception as exc :
308310 last_exception = exc
309311 break
310312 print ("Failed to establish connection with worker:" , last_exception )
311- sys .exit (2 )
312313
313314 def close (self ) -> None :
314315 self .conn .close ()
@@ -394,6 +395,8 @@ def default_flush_errors(
394395 def connect (wc : WorkerClient , data : bytes ) -> None :
395396 # Start loading sources in each worker as soon as it is up.
396397 wc .connect ()
398+ if not wc .connected :
399+ return
397400 wc .conn .write_bytes (data )
398401
399402 # We don't wait for workers to be ready until they are actually needed.
@@ -432,6 +435,8 @@ def connect(wc: WorkerClient, data: bytes) -> None:
432435 for thread in connect_threads :
433436 thread .join ()
434437 for worker in workers :
438+ if not worker .connected :
439+ continue
435440 try :
436441 send (worker .conn , SccRequestMessage (scc_id = None , import_errors = {}, mod_data = {}))
437442 except (OSError , IPCException ):
@@ -3972,6 +3977,8 @@ def dispatch(
39723977 # Wait for workers since they may be needed at this point.
39733978 for thread in connect_threads :
39743979 thread .join ()
3980+ if not all (wc .connected for wc in manager .workers ):
3981+ raise OSError ("Build workers failed to start" )
39753982 process_graph (graph , manager )
39763983 # Update plugins snapshot.
39773984 write_plugins_snapshot (manager )
0 commit comments