Function
wait_for_socket
(path: Path, timeout_s: float = 20.0)
Source from the content-addressed store, hash-verified
| 111 | |
| 112 | |
| 113 | def 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 | # ────────────────────────────────────────────────────────────────────────────── |
Tested by
no test coverage detected