Server IP : 15.235.198.142 / Your IP : 216.73.216.190 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ballsack 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/landscape/lib/__pycache__/ |
Upload File : |
� �~�e� � � � d dl Z G d� d� Zy)� Nc �0 � e Zd ZdZd� 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 � | xj dz c_ t | j d� | _ y)z0Decreases error count with zero being the lowest� r N)r �max�r s r �decreasezExponentialBackoff.decrease s( � ����Q����� 1� 1�1�5��r c �j � | j � | j k r| xj dz c_ yy)z=Increases error count but not higher than gives the max delayr N)� get_delayr r r s r �increasezExponentialBackoff.increase s+ � ��>�>��d�o�o�-�����"�� .r c � � | j r d| j dz z | j z }nd}t t |� | 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) � r r )r r �min�intr )r �delays r r zExponentialBackoff.get_delay sG � � ����4�,�,�q�0�1�T�5F�5F�F�E��E��3�u�:�t���/�/r c � � | j � }|d|z z }||z t j � 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�1r N)g �?) �__name__� __module__�__qualname__�__doc__r r r r r! � r r r r s � �� $�6� #� 0�$2r r )r r r&