Skip to main content

port_utils

is_available

def is_available(host: str, port: int) -> bool

Check if a given (host, port) pair is available (i.e. there could be another server running already)

Arguments:

  • host: host to test
  • port: port to test

find_available_port

def find_available_port(host: str, from_port: int, to_port: int)

Search the specified (from, to) port space to find an available one

Raises if no port is available

Arguments:

  • host: host
  • from_port: port to start search from
  • to_port: port to finish search on