Exemplo n.º 1
0
 def throttled(self):
     should = EDTime.py_epoch_now() < self.backoff_until
     if should:
         EDRLOG.log(u"Exponential backoff still active for {} API calls: attempts={}, until={}".format(self.name, self.attempts, EDTime.t_plus_py(self.backoff_until)), u"DEBUG")
     return should
Exemplo n.º 2
0
 def throttle(self):
     self.attempts += 1
     delay = min(self.cap, self.base * 2 ** self.attempts) + random.randint(0, 60)
     self.backoff_until = EDTime.py_epoch_now() + delay
     EDRLOG.log(u"Exponential backoff for {} API calls: attempts={}, until={}".format(self.name, self.attempts, EDTime.t_plus_py(self.backoff_until)), u"DEBUG")