def calculate_wait_for_retry(retry_attempt, max_wait=60):
    """Calculate the amount of time to wait before a retry attempt.

    Wait time grows exponentially with the number of attempts. A
    random amount of jitter is added to spread out retry attempts from
    different clients.

    :type retry_attempt: integer
    :param retry_attempt: Retry attempt counter.

    :type max_wait: integer
    :param max_wait: Upper bound for wait time [seconds].

    :rtype: integer
    :returns: Number of seconds to wait before retrying request.
    """

    wait_time = 2 ** retry_attempt
    max_jitter = wait_time / 4.0
    wait_time += random.uniform(-max_jitter, max_jitter)
    return max(1, min(wait_time, max_wait))
dataset/ETHPy150Open GoogleCloudPlatform/gcloud-python/gcloud/streaming/util.py/calculate_wait_for_retry/original