
    (ph                     z    S SK r S SKrS SKrS SKJr  SrSrSrSr  " S S5      r	 " S	 S
\	5      r
 " S S\	5      rg)    N)
exceptions   g      ?g?g       @c                   V    \ rS rSrSr\\\\4S jr	\
S 5       r\
S 5       rS rS rSrg	)
_BaseExponentialBackoff*   a  An exponential backoff iterator base class.

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                     US:  a  [         R                  " SU 35      eXl        X l        U R                  U l        X0l        X@l        SU l        g )N   z:total_attempts must be greater than or equal to 1 but was r   )r   InvalidValue_total_attempts_initial_wait_seconds_current_wait_in_seconds_randomization_factor_multiplier_backoff_count)selftotal_attemptsinitial_wait_secondsrandomization_factor
multipliers        S/var/www/html/venv/lib/python3.13/site-packages/google/auth/_exponential_backoff.py__init__ _BaseExponentialBackoff.__init__B   sZ     A))L^L\]   .%9"(,(B(B%%9"%    c                     U R                   $ )z7The total amount of backoff attempts that will be made.)r   r   s    r   r   &_BaseExponentialBackoff.total_attemptsW   s     ###r   c                     U R                   $ )z;The current amount of backoff attempts that have been made.)r   r   s    r   backoff_count%_BaseExponentialBackoff.backoff_count\   s     """r   c                 4    SU l         U R                  U l        g )Nr   )r   r   r   r   s    r   _reset_BaseExponentialBackoff._reseta   s    (,(B(B%r   c                     U R                   U R                  -  n[        R                  " U R                   U-
  U R                   U-   5      nU$ N)r   r   randomuniform)r   jitter_variancejitters      r   _calculate_jitter)_BaseExponentialBackoff._calculate_jittere   sI    77$:T:TT))O;))O;

 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   propertyr   r   r!   r)   __static_attributes__ r   r   r   r   *   sM    2 5>:& * $ $ # #Cr   r   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )ExponentialBackoffo   znAn exponential backoff iterator. This can be used in a for loop to
perform requests with exponential backoff.
c                 .   > [         [        U ]
  " U0 UD6  g r$   )superr8   r   r   argskwargs	__class__s      r   r   ExponentialBackoff.__init__t   s     $0$A&Ar   c                 &    U R                  5         U $ r$   r!   r   s    r   __iter__ExponentialBackoff.__iter__w       r   c                 F   U R                   U R                  :  a  [        eU =R                   S-  sl         U R                   S::  a  U R                   $ U R                  5       n[        R
                  " U5        U =R                  U R                  -  sl        U R                   $ Nr	   )r   r   StopIterationr)   timesleepr   r   r   r(   s     r   __next__ExponentialBackoff.__next__{   s    $"6"66q !#&&&'')

6%%)9)99%"""r   r6   )
r+   r,   r-   r.   r/   r   rC   rL   r5   __classcell__r?   s   @r   r8   r8   o   s    B# #r   r8   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )AsyncExponentialBackoff   zzAn async exponential backoff iterator. This can be used in a for loop to
perform async requests with exponential backoff.
c                 .   > [         [        U ]
  " U0 UD6  g r$   )r;   rQ   r   r<   s      r   r    AsyncExponentialBackoff.__init__   s    %t5tFvFr   c                 &    U R                  5         U $ r$   rB   r   s    r   	__aiter__!AsyncExponentialBackoff.__aiter__   rE   r   c                 b  #    U R                   U R                  :  a  [        eU =R                   S-  sl         U R                   S::  a  U R                   $ U R                  5       n[        R
                  " U5      I S h  vN   U =R                  U R                  -  sl        U R                   $  N/7frG   )r   r   StopAsyncIterationr)   asynciorJ   r   r   rK   s     r   	__anext__!AsyncExponentialBackoff.__anext__   s     $"6"66$$q !#&&&'')mmF###%%)9)99%""" 	$s   A;B/=B->0B/r6   )
r+   r,   r-   r.   r/   r   rV   r[   r5   rN   rO   s   @r   rQ   rQ      s    G# #r   rQ   )rZ   r%   rI   google.authr   r0   r1   r2   r3   r   r8   rQ   r6   r   r   <module>r^      s_       " !"  %( ! !$   B BJ#0 #8#5 #r   