
    U                     :    S SK r S SKrSrSrSrSr  " S S5      rg)    N   g      ?g?g       @c                   V    \ rS rSrSr\\\\4S jr	S r
S r\S 5       r\S 5       rSrg	)
ExponentialBackoff(   a  An exponential backoff iterator. This can be used in a for loop to
perform requests with exponential backoff.

Args:
    total_attempts Optional[int]:
        The maximum amount of retries that should happen.
        The default value is 3 attempts.
    initial_wait_seconds Optional[int]:
        The amount of time to sleep in the first backoff. This parameter
        should be in seconds.
        The default value is 1 second.
    randomization_factor Optional[float]:
        The amount of jitter that should be in each backoff. For example,
        a value of 0.1 will introduce a jitter range of 10% to the
        current backoff period.
        The default value is 0.1.
    multiplier Optional[float]:
        The backoff multipler. This adjusts how much each backoff will
        increase. For example a value of 2.0 leads to a 200% backoff
        on each attempt. If the initial_wait is 1.0 it would look like
        this sequence [1.0, 2.0, 4.0, 8.0].
        The default value is 2.0.
c                 d    Xl         X l        U R                  U l        X0l        X@l        SU l        g Nr   )_total_attempts_initial_wait_seconds_current_wait_in_seconds_randomization_factor_multiplier_backoff_count)selftotal_attemptsinitial_wait_secondsrandomization_factor
multipliers        ;platform/bq/third_party/google/auth/_exponential_backoff.py__init__ExponentialBackoff.__init__A   s2      .%9"(,(B(B%%9"%    c                 6    SU l         U R                  U l        U $ r   )r   r
   r   r   s    r   __iter__ExponentialBackoff.__iter__Q   s    (,(B(B%r   c                    U R                   U R                  :  a  [        eU =R                   S-  sl         U R                  U R                  -  n[
        R                  " U R                  U-
  U R                  U-   5      n[        R                  " U5        U =R                  U R                  -  sl        U R                   $ )N   )
r   r	   StopIterationr   r   randomuniformtimesleepr   )r   jitter_variancejitters      r   __next__ExponentialBackoff.__next__V   s    $"6"66q 77$:T:TT))O;))O;

 	

6%%)9)99%"""r   c                     U R                   $ )z7The total amount of backoff attempts that will be made.)r	   r   s    r   r   !ExponentialBackoff.total_attemptsf   s     ###r   c                     U R                   $ )z;The current amount of backoff attempts that have been made.)r   r   s    r   backoff_count ExponentialBackoff.backoff_countk   s     """r   )r   r   r
   r   r   r	   N)__name__
__module____qualname____firstlineno____doc___DEFAULT_RETRY_TOTAL_ATTEMPTS!_DEFAULT_INITIAL_INTERVAL_SECONDS_DEFAULT_RANDOMIZATION_FACTOR_DEFAULT_MULTIPLIERr   r   r%   propertyr   r*   __static_attributes__ r   r   r   r   (   sL    4 5>:&  
#  $ $ # #r   r   )r   r!   r1   r2   r3   r4   r   r7   r   r   <module>r8      s>       !"  %( ! !$   F# F#r   