a
    w=icY  ã                   @   s>   d dl Z d dlZd dlZdZdZdZdZG dd„ dejƒZdS )é    Né   g      ð?gš™™™™™¹?g       @c                   @   sJ   e Zd ZdZeeeefdd„Zdd„ Z	dd„ Z
edd	„ ƒZed
d„ ƒZdS )Ú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                 C   s*   || _ || _| j| _|| _|| _d| _d S ©Nr   )Ú_total_attemptsÚ_initial_wait_secondsÚ_current_wait_in_secondsÚ_randomization_factorÚ_multiplierÚ_backoff_count)ÚselfÚtotal_attemptsZinitial_wait_secondsZrandomization_factorÚ
multiplier© r   úq/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/google/auth/_exponential_backoff.pyÚ__init__B   s    zExponentialBackoff.__init__c                 C   s   d| _ | j| _| S r   )r
   r   r   ©r   r   r   r   Ú__iter__R   s    zExponentialBackoff.__iter__c                 C   sb   | j | jkrt‚|  j d7  _ | j| j }t | j| | j| ¡}t |¡ |  j| j	9  _| j S )Né   )
r
   r   ÚStopIterationr   r   ÚrandomÚuniformÚtimeÚsleepr	   )r   Zjitter_varianceÚjitterr   r   r   Ú__next__W   s    þ
zExponentialBackoff.__next__c                 C   s   | j S )z7The total amount of backoff attempts that will be made.)r   r   r   r   r   r   g   s    z!ExponentialBackoff.total_attemptsc                 C   s   | j S )z;The current amount of backoff attempts that have been made.)r
   r   r   r   r   Úbackoff_countl   s    z ExponentialBackoff.backoff_countN)Ú__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   r   )   s   û

r   )	r   r   Úsixr    r!   r"   r#   ÚIteratorr   r   r   r   r   Ú<module>   s   
