/usr/lib/python3/dist-packages/landscape/lib
NameSizeModeActions
apt/-0755rm
__pycache__/-0755rm
amp.py217450644editdlrm
backoff.py16830644editdlrm
base64.py1960644editdlrm
bootstrap.py14160644editdlrm
bpickle.py64710644editdlrm
cli.py4400644editdlrm
cloud.py17150644editdlrm
compat.py6160644editdlrm
config.py124840644editdlrm
disk.py50270644editdlrm
encoding.py5450644editdlrm
fd.py7510644editdlrm
fetch.py66470644editdlrm
format.py9590644editdlrm
fs.py38890644editdlrm
gpg.py17960644editdlrm
hashlib.py2640644editdlrm
jiffies.py16210644editdlrm
juju.py8600644editdlrm
lock.py7050644editdlrm
log.py4840644editdlrm
logging.py25280644editdlrm
message.py26380644editdlrm
monitor.py62810644editdlrm
network.py98210644editdlrm
os_release.py13240644editdlrm
persist.py209950644editdlrm
plugin.py17870644editdlrm
process.py66030644editdlrm
reactor.py88120644editdlrm
schema.py64570644editdlrm
scriptcontent.py5220644editdlrm
sequenceranges.py57240644editdlrm
store.py14080644editdlrm
sysstats.py79200644editdlrm
tag.py5060644editdlrm
testing.py246620644editdlrm
timestamp.py2330644editdlrm
twisted_util.py44760644editdlrm
user.py14760644editdlrm
versioning.py12650644editdlrm
vm_info.py31720644editdlrm
warning.py3940644editdlrm
__init__.py1980644editdlrm
Edit: /usr/lib/python3/dist-packages/landscape/lib/backoff.py (1683B)
import random class ExponentialBackoff: """ Keeps track of a backoff delay that staggers down and staggers up exponentially. """ def __init__(self, start_delay, max_delay): self._error_count = 0 # A tally of server errors self._start_delay = start_delay self._max_delay = max_delay def decrease(self): """Decreases error count with zero being the lowest""" self._error_count -= 1 self._error_count = max(self._error_count, 0) def increase(self): """Increases error count but not higher than gives the max delay""" if self.get_delay() < self._max_delay: self._error_count += 1 def get_delay(self): """ 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) """ if self._error_count: delay = (2 ** (self._error_count - 1)) * self._start_delay else: delay = 0 return min(int(delay), self._max_delay) def get_random_delay(self, stagger_fraction=0.25): """ 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) """ delay = self.get_delay() non_random_part = delay * (1-stagger_fraction) random_part = delay * stagger_fraction * random.random() return int(non_random_part + random_part)