HOME


Mini Shell 1.0
DIR: /lib/python3/dist-packages/landscape/lib/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/landscape/lib/__pycache__/backoff.cpython-312.pyc
�

�~�e��� �ddlZGd�d�Zy)�Nc�0�eZdZdZd�Zd�Zd�Zd�Zdd�Zy)	�ExponentialBackoffz^
    Keeps track of a backoff delay that staggers down and staggers up
    exponentially.
    c�.�d|_||_||_y)Nr)�_error_count�_start_delay�
_max_delay)�self�start_delay�	max_delays   �7/usr/lib/python3/dist-packages/landscape/lib/backoff.py�__init__zExponentialBackoff.__init__
s�����'���#���c�d�|xjdzc_t|jd�|_y)z0Decreases error count with zero being the lowest�rN)r�max�r	s r�decreasezExponentialBackoff.decreases(�����Q����� 1� 1�1�5��rc�j�|j�|jkr|xjdz
c_yy)z=Increases error count but not higher than gives the max delayrN)�	get_delayrrrs r�increasezExponentialBackoff.increases+���>�>��d�o�o�-�����"��.rc��|jr d|jdz
z|jz}nd}tt|�|j�S)aR
        Calculates the delay using formula that gives this chart. In this
        specific example start is 5 seconds and max is 60 seconds
                Count  Delay
                0      0
                1      5
                2      10
                3      20
                4      40
                5      60 (max)
        �rr)rr�min�intr)r	�delays  rrzExponentialBackoff.get_delaysG������4�,�,�q�0�1�T�5F�5F�F�E��E��3�u�:�t���/�/rc��|j�}|d|z
z}||ztj�z}t||z�S)z�
        Adds randomness to the specified stagger of the delay. For example
        for a delay of 12 and 25% stagger, it works out to 9 + rand(0,3)
        r)r�randomr)r	�stagger_fractionr�non_random_part�random_parts     r�get_random_delayz#ExponentialBackoff.get_random_delay-sF��
��� ���1�'7�#7�8���.�.�����@���?�[�0�1�1rN)g�?)	�__name__�
__module__�__qualname__�__doc__r
rrrr!�rrrrs ���
$�6�
#�
0�$2rr)rrr&rr�<module>r's��
�12�12r