Skip to main content

Python function

available_port

available_port()

max.kv_cache.available_port(start_port=8000, end_port=9000, max_attempts=100)

source

Finds an available TCP port in the given range.

Parameters:

  • start_port (int) – The lower bound of the port range (inclusive).
  • end_port (int) – The upper bound of the port range (inclusive).
  • max_attempts (int) – Maximum number of attempts to find a free port.

Returns:

An available port number.

Return type:

int

Raises:

RuntimeError – If no available port is found after max_attempts.