MCPcopy Create free account
hub / github.com/Luce-Org/lucebox-hub / wait_server

Function wait_server

server/scripts/test_prefill_cache.py:75–86  ·  view source on GitHub ↗
(proc: subprocess.Popen, deadline_s: int = 240)

Source from the content-addressed store, hash-verified

73
74
75def wait_server(proc: subprocess.Popen, deadline_s: int = 240) -> None:
76 deadline = time.time() + deadline_s
77 while time.time() < deadline:
78 if proc.poll() is not None:
79 tail = LOG_PATH.read_text(errors="replace")[-4000:] if LOG_PATH.exists() else ""
80 raise RuntimeError(f"server exited early; log tail:\n{tail}")
81 try:
82 get_json("/v1/models", timeout=1)
83 return
84 except (urllib.error.URLError, ConnectionResetError, TimeoutError):
85 time.sleep(1)
86 raise RuntimeError(f"server did not become ready within {deadline_s}s")
87
88
89def main() -> int:

Callers 1

mainFunction · 0.85

Calls 1

get_jsonFunction · 0.85

Tested by

no test coverage detected