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

Function wait_for_socket

scripts/profile_single_spawn.py:26–39  ·  view source on GitHub ↗
(path: Path, timeout_s: float = 10.0)

Source from the content-addressed store, hash-verified

24
25
26def wait_for_socket(path: Path, timeout_s: float = 10.0) -> None:
27 deadline = time.time() + timeout_s
28 while time.time() < deadline:
29 if path.exists():
30 try:
31 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
32 sock.settimeout(0.2)
33 sock.connect(str(path))
34 sock.close()
35 return
36 except OSError:
37 pass
38 time.sleep(0.01)
39 raise RuntimeError(f"socket not ready: {path}")
40
41
42def create_session(debug_sock: Path, cwd: str) -> str:

Callers 1

profile_single_spawnFunction · 0.70

Calls 2

connectMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected