(host: str, port: int, *, timeout: float)
| 327 | |
| 328 | |
| 329 | def _wait_for_socket(host: str, port: int, *, timeout: float) -> None: |
| 330 | import socket |
| 331 | |
| 332 | deadline = time.monotonic() + timeout |
| 333 | while time.monotonic() < deadline: |
| 334 | with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: |
| 335 | s.settimeout(1.0) |
| 336 | try: |
| 337 | s.connect((host, port)) |
| 338 | return |
| 339 | except OSError: |
| 340 | time.sleep(0.5) |
| 341 | raise RuntimeError(f"Server at {host}:{port} did not accept connections within {timeout:.0f}s") |
| 342 | |
| 343 | |
| 344 | def cmd_prepare(args: argparse.Namespace) -> int: |
no test coverage detected