haiku.rag/tests/services.py
2026-06-04 11:13:16 +03:00

11 lines
380 B
Python

import socket
def reachable(host: str, port: int, timeout: float = 1.0) -> bool:
"""True if a TCP connection to host:port succeeds within timeout. Used by
integration tests to skip when their backing service isn't running."""
try:
with socket.create_connection((host, port), timeout=timeout):
return True
except OSError:
return False