From ecf0d06090f8899187e42cb4f49e0f239345df2f Mon Sep 17 00:00:00 2001 From: Steve Kreitzer Date: Sun, 22 May 2022 00:56:14 -0500 Subject: [PATCH] Support at_front requeue support (#1657) Co-authored-by: Steve Kreitzer --- rq/job.py | 4 ++-- rq/registry.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rq/job.py b/rq/job.py index 4cb12528..2901ae50 100644 --- a/rq/job.py +++ b/rq/job.py @@ -734,9 +734,9 @@ class Job: # handle it raise - def requeue(self): + def requeue(self, at_front=False): """Requeues job.""" - return self.failed_job_registry.requeue(self) + return self.failed_job_registry.requeue(self, at_front=at_front) def _remove_from_registries(self, pipeline=None, remove_from_queue=True): if remove_from_queue: diff --git a/rq/registry.py b/rq/registry.py index e9652ad9..089a7873 100644 --- a/rq/registry.py +++ b/rq/registry.py @@ -110,7 +110,7 @@ class BaseRegistry: score = self.connection.zscore(self.key, job.id) return datetime.utcfromtimestamp(score) - def requeue(self, job_or_id): + def requeue(self, job_or_id, at_front=False): """Requeues the job with the given job ID.""" if isinstance(job_or_id, self.job_class): job = job_or_id @@ -130,7 +130,7 @@ class BaseRegistry: job.ended_at = None job.exc_info = '' job.save() - job = queue.enqueue_job(job, pipeline=pipeline) + job = queue.enqueue_job(job, pipeline=pipeline, at_front=at_front) pipeline.execute() return job