hoops_ai.insights.find_free_port

hoops_ai.insights.find_free_port(start_port=8000, max_attempts=100, host='127.0.0.1')

Find a free port starting from a given port number.

Parameters:
  • start_port (int) – Port number to start searching from (default: 8000)

  • max_attempts (int) – Maximum number of ports to try (default: 100)

  • host (str) – Host address to check (default: ‘127.0.0.1’)

Returns:

First available port number, or None if no port found

Return type:

int

Examples

>>> port = find_free_port()
>>> print(f"Found free port: {port}")
>>> port = find_free_port(start_port=9000)  # Start from 9000