IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Python function

available_port

available_port()​

max.pipelines.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.