MCPcopy Create free account
hub / github.com/1jehuang/jcode / wait_for_socket

Function wait_for_socket

scripts/bench_startup.py:117–129  ·  view source on GitHub ↗
(path: str, timeout_s: float)

Source from the content-addressed store, hash-verified

115
116
117def wait_for_socket(path: str, timeout_s: float) -> bool:
118 deadline = time.perf_counter() + timeout_s
119 while time.perf_counter() < deadline:
120 if os.path.exists(path):
121 try:
122 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
123 sock.connect(path)
124 sock.close()
125 return True
126 except OSError:
127 pass
128 time.sleep(0.005)
129 return False
130
131
132def measure_server_startup(binary: str, runs: int) -> list[float]:

Callers 1

measure_server_startupFunction · 0.70

Calls 2

connectMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected