openhands.runtime.utils.system
find_available_tcp_port
def find_available_tcp_port(min_port=30000,
max_port=39999,
max_attempts=10) -> int
Find an available TCP port in a specified range.
Arguments:
min_port
int - The lower bound of the port range (default: 30000)max_port
int - The upper bound of the port range (default: 39999)max_attempts
int - Maximum number of attempts to find an available port (default: 10)
Returns:
int
- An available port number, or -1 if none found after max_attempts