def calculate_wait_for_retry(retry_attempt):
 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_RETRY_WAIT))

def calculate_wait_for_retry ( retry_attempt ) : 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_RETRY_WAIT ) )
calculate the amount of time to wait before a retry attempt .