/usr/lib/python3/dist-packages/landscape/lib/__pycache__
Edit: /usr/lib/python3/dist-packages/landscape/lib/__pycache__/backoff.cpython-310.pyc (2137B)
o
c @ s d dl Z G dd dZdS ) Nc @ s: e Zd ZdZdd Zdd Zdd Zdd ZdddZd
S )ExponentialBackoffz^
Keeps track of a backoff delay that staggers down and staggers up
exponentially.
c C s d| _ || _|| _d S )Nr )_error_count_start_delay
_max_delay)selfstart_delay max_delay r 7/usr/lib/python3/dist-packages/landscape/lib/backoff.py__init__
s
zExponentialBackoff.__init__c C s | j d8 _ t| j d| _ dS )z0Decreases error count with zero being the lowest r N)r maxr r r r
decrease s zExponentialBackoff.decreasec C s$ | | jk r| jd7 _dS dS )z=Increases error count but not higher than gives the max delayr N) get_delayr r r r r r
increase s zExponentialBackoff.increasec C s0 | j rd| j d | j }nd}tt|| jS )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 minintr )r delayr r r
r s zExponentialBackoff.get_delay ?c C s0 | }|d| }|| t }t|| 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_partrandom_partr r r
get_random_delay- s z#ExponentialBackoff.get_random_delayN)r ) __name__
__module____qualname____doc__r r r r r r r r r
r s r )r r r r r r
s