
    Thg                     F    d dl Z d dlZd dlmZ dZdZdZdZ	  G d d      Zy)	    N)
exceptions   g      ?g?g       @c                   L    e Zd ZdZeeeefdZd Z	d Z
ed        Zed        Zy)ExponentialBackoffa>  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k  rt        j                  d|       || _        || _        | j                  | _        || _        || _        d| _        y )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        `/opt/server/standalone/crm/venv/lib/python3.12/site-packages/google/auth/_exponential_backoff.py__init__zExponentialBackoff.__init__B   sb     A))L^L\]   .%9"(,(B(B%%9"%    c                 6    d| _         | j                  | _        | S )Nr   )r   r   r   r   s    r   __iter__zExponentialBackoff.__iter__W   s    (,(B(B%r   c                    | j                   | j                  k\  rt        | xj                   dz  c_         | j                   dk  r| j                   S | j                  | j                  z  }t        j                  | j                  |z
  | j                  |z         }t        j                  |       | xj                  | j                  z  c_        | j                   S )Nr   )
r   r
   StopIterationr   r   randomuniformtimesleepr   )r   jitter_variancejitters      r   __next__zExponentialBackoff.__next__\   s    $"6"66q !#&&&77$:T:TT))O;))O;

 	

6%%)9)99%"""r   c                     | j                   S )z7The total amount of backoff attempts that will be made.)r
   r   s    r   r   z!ExponentialBackoff.total_attemptso   s     ###r   c                     | j                   S )z;The current amount of backoff attempts that have been made.)r   r   s    r   backoff_countz ExponentialBackoff.backoff_countt   s     """r   N)__name__
__module____qualname____doc___DEFAULT_RETRY_TOTAL_ATTEMPTS!_DEFAULT_INITIAL_INTERVAL_SECONDS_DEFAULT_RANDOMIZATION_FACTOR_DEFAULT_MULTIPLIERr   r   r#   propertyr   r&    r   r   r   r   )   sL    4 5>:& *
#& $ $ # #r   r   )	r   r   google.authr   r+   r,   r-   r.   r   r0   r   r   <module>r2      sA      " !"  %( ! !$   N# N#r   