hgicommon/helpers.py
def get_open_port() -> int:
    """
    Gets a PORT that will (probably) be available on the machine.
    It is possible that in-between the time in which the open PORT of found and when it is used, another process may
    bind to it instead.
    :return: the (probably) available PORT
    """
    free_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    free_socket.bind(("", 0))
    free_socket.listen(1)
    port = free_socket.getsockname()[1]
    free_socket.close()
    return port
def get_open_port() -> int:
    """
    Gets a PORT that will (probably) be available on the machine.
    It is possible that in-between the time in which the open PORT of found and when it is used, another process may
    bind to it instead.
    :return: the (probably) available PORT
    """
    free_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    free_socket.bind(("", 0))
    free_socket.listen(1)
    port = free_socket.getsockname()[1]
    free_socket.close()
    return port
def get_open_port ( ) -> int : free_socket = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) free_socket . bind ( ( "" , 0 ) ) free_socket . listen ( 1 ) port = free_socket . getsockname ( ) [ 1 ] free_socket . close ( ) return port
Gets a PORT that will (probably) be available on the machine.
    It is possible that in-between the time in which the open PORT of found and when it is used, another process may
    bind to it instead.
    :return: the (probably) available PORT
Gets a PORT that will ( probably ) be available on the machine . It is possible that in - between the time in which the open PORT of found and when it is used another process may bind to it instead . : return : the ( probably ) available PORT