Returns random unused port number.

def select_random(ports=None, exclude_ports=None):
    """
    Returns random unused port number.
    """
    if ports is None:
        ports = available_good_ports()

    if exclude_ports is None:
        exclude_ports = set()

    ports.difference_update(set(exclude_ports))

    for port in random.sample(ports, min(len(ports), 100)):
        if not port_is_used(port):
            return port
    raise PortForException("Can't select a port")