'Use a temporary socket to elicit an unused ephemeral port.
Args:
bind_address: Hostname or IP address to search for a port on.
Returns: A most likely to be unused port.'

def _get_unused_port(self, bind_address='0.0.0.0'):

    tempsock = socket.socket()
    tempsock.bind((bind_address, 0))
    (host, port) = tempsock.getsockname()
    tempsock.close()
    return port
