def retry_increment(self, key, value): self.RETRIES += 1 if self.RETRIES <= self.MAX_RETRIES: logger.error("sleeping some seconds before reconnecting") time.sleep(2 * self.RETRIES) return self.increment(key, value) else: self.RETRIES = 0 raise RConnectionError('Redis instance is unavailable')
def retry_call(self, key, f, time_expire, with_lock): self.RETRIES += 1 if self.RETRIES <= self.MAX_RETRIES: logger.error("sleeping %s seconds before reconnecting" % (2 * self.RETRIES)) time.sleep(2 * self.RETRIES) if self.fail_gracefully: self.RETRIES = 0 return f() return self.__call__(key, f, time_expire, with_lock) else: self.RETRIES = 0 if self.fail_gracefully: return f raise RConnectionError('Redis instance is unavailable')