def retry(self, payload_class, args): retry_every = getattr(payload_class, "retry_every", None) retry_timeout = getattr(payload_class, "retry_timeout", 0) if retry_every: now = ResQ._utcnow() first_attempt = self._payload.get("first_attempt", now) retry_until = first_attempt + timedelta(seconds=retry_timeout) retry_at = now + timedelta(seconds=retry_every) if retry_at < retry_until: self.resq.enqueue_at(retry_at, payload_class, *args, **{"first_attempt": first_attempt}) return True return False
def perform(fail_until): if ResQ._utcnow() < fail_until: raise Exception("Don't blame me! I'm supposed to fail!") else: return True