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

Function wait_for_socket

scripts/repro_live_duplicate.py:113–126  ·  view source on GitHub ↗
(path: Path, timeout_s: float = 20.0)

Source from the content-addressed store, hash-verified

111
112
113def wait_for_socket(path: Path, timeout_s: float = 20.0) -> None:
114 deadline = time.time() + timeout_s
115 while time.time() < deadline:
116 if path.exists():
117 try:
118 s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
119 s.settimeout(0.2)
120 s.connect(str(path))
121 s.close()
122 return
123 except OSError:
124 pass
125 time.sleep(0.02)
126 raise RuntimeError(f"socket not ready: {path}")
127
128
129# ──────────────────────────────────────────────────────────────────────────────

Callers 1

mainFunction · 0.70

Calls 2

connectMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected