harp.utils.network¶
- class PortReservationManager[source]¶
Bases:
objectManages port reservations to prevent race conditions.
- get_reserved_port()[source]¶
Get an available port with reservation to prevent race conditions.
- Return type:
- wait_for_port(port, host='localhost', timeout=10.0)[source]¶
Wait until a port starts accepting TCP connections. Args:
port: Port number. host: Host address on which the port should exist. timeout: In seconds. How long to wait before raising errors.
- Raises:
TimeoutError: The port isn’t accepting connection after time specified in timeout.
- async wait_for_service_ready(port, host='localhost', health_path=None, custom_check=None, timeout=10.0, retry_interval=0.1)[source]¶
Wait for a service to be ready by checking health endpoint or custom check.
- Args:
port: Port number. host: Host address. health_path: Optional health check endpoint path. custom_check: Optional custom readiness check function. timeout: Total timeout in seconds. retry_interval: Time between retries in seconds.
- Raises:
TimeoutError: If service is not ready within timeout.