def METHOD_NAME(port, timeout):
    for i in range(timeout):
        if not detect_port(port):
            return
        warnings.warn("Port isn't available in {} seconds (patience: {})".format(i, timeout), RuntimeWarning)
        time.sleep(1)
    msg = 'Port {} is not available in {} seconds. Maybe the previous experiment fails to stop?'.format(port, timeout)
    raise RuntimeError(msg)