def wait_duration(attempt):
    """ Calculate the wait time based on the number of past attempts.
    The time grows exponentially with the attempts up to a maximum
    of 10 seconds.
    Args:
        attempt: Current count of reconnection attempts.
    Returns:
        int: The number of seconds to wait before next attempt
    """
    return min(10, pow(2, attempt))