Let CI server launches wait longer for ports held by a dying predecessor (#31281)

This commit is contained in:
Alison Shao
2026-07-17 21:45:24 -07:00
committed by GitHub
parent 44e4999ab2
commit a5c0b94034
2 changed files with 15 additions and 1 deletions
+10 -1
View File
@@ -54,8 +54,17 @@ MAX_VALID_PORT = 65535
def wait_port_available(
port: int, port_name: str, timeout_s: int = 30, raise_exception: bool = True
port: int,
port_name: str,
timeout_s: Optional[int] = None,
raise_exception: bool = True,
) -> bool:
if timeout_s is None:
# A killed server can hold its ports well past kill_process_tree()'s
# return while GPU teardown completes (>30s observed on GB300), so CI
# raises this via SGLANG_WAIT_PORT_TIMEOUT before relaunching a server
# on the same port plan.
timeout_s = int(os.environ.get("SGLANG_WAIT_PORT_TIMEOUT", "30"))
if port < 0 or port > MAX_VALID_PORT:
raise ValueError(
f"{port_name} has invalid port number {port}. "
+5
View File
@@ -927,6 +927,11 @@ def popen_launch_server(
merged.update(env)
env = merged
# A dying predecessor can hold the derived port plan past
# kill_process_tree() while GPU teardown completes; give CI launches
# teardown-sized patience (see wait_port_available).
env.setdefault("SGLANG_WAIT_PORT_TIMEOUT", "120")
# Store per-run marker path for potential invalidation
per_run_marker_path = None
try: