def _await_nailgun_server(self, workunit):
nailgun_timeout_seconds = 5
max_socket_connect_attempts = 10
nailgun = None
port_parse_start = time.time()
with _safe_open(self._ng_out, "r") as ng_out:
while not nailgun:
started = ng_out.readline()
if started:
port = self._parse_nailgun_port(started)
with open(self._pidfile, "a") as pidfile:
pidfile.write(":%d\n" % port)
nailgun = self._create_ngclient(port, workunit)
log.debug("Detected ng server up on port %d" % port)
elif time.time() - port_parse_start > nailgun_timeout_seconds:
raise NailgunError("Failed to read ng output after %s seconds" % nailgun_timeout_seconds)
After Change
start = time.time()
endpoint = self._get_nailgun_endpoint()
while endpoint is None:
if time.time() - start > nailgun_timeout_seconds:
raise NailgunError("Failed to read ng output after %s seconds" % nailgun_timeout_seconds)
time.sleep(0.1)endpoint = self._get_nailgun_endpoint()
port = endpoint[1]
nailgun = self._create_ngclient(port, workunit)
log.debug("Detected ng server up on port %d" % port)