From fc9610ae53af938e3ff53907dd6feb523756397f Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Sun, 13 Oct 2024 07:08:54 +0700 Subject: [PATCH] Added `desc` argument to registry.get_job_ids() (#2129) * Added `desc` argument to registry.get_job_ids() * Added argument description to registry.get_job_ids() --- rq/registry.py | 7 ++++--- rq/worker.py | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/rq/registry.py b/rq/registry.py index f86e7099..42568543 100644 --- a/rq/registry.py +++ b/rq/registry.py @@ -153,18 +153,19 @@ class BaseRegistry: expired_jobs = self.connection.zrangebyscore(self.key, 0, score) return [as_text(job_id) for job_id in expired_jobs] - def get_job_ids(self, start: int = 0, end: int = -1): + def get_job_ids(self, start: int = 0, end: int = -1, desc: bool = False): """Returns list of all job ids. Args: start (int, optional): _description_. Defaults to 0. end (int, optional): _description_. Defaults to -1. + end (bool, optional): _description_. Defaults to False. Returns: _type_: _description_ """ self.cleanup() - return [as_text(job_id) for job_id in self.connection.zrange(self.key, start, end)] + return [as_text(job_id) for job_id in self.connection.zrange(self.key, start, end, desc=desc)] def get_queue(self): """Returns Queue object associated with this registry.""" @@ -207,7 +208,7 @@ class BaseRegistry: queue = Queue(job.origin, connection=self.connection, job_class=self.job_class, serializer=serializer) job.started_at = None job.ended_at = None - job._exc_info = '' + job._exc_info = '' # TODO: this should be removed job.save() job = queue._enqueue_job(job, pipeline=pipeline, at_front=at_front) pipeline.execute() diff --git a/rq/worker.py b/rq/worker.py index 78a8af47..1e1bc953 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -612,7 +612,7 @@ class BaseWorker: def cleanup_execution(self, job: 'Job', pipeline: 'Pipeline'): """Cleans up the execution of a job. - It will remove the job from the `StartedJobRegistry` and deleting the Execution object. + It will remove the job from the `StartedJobRegistry` and delete the Execution object. """ started_job_registry = StartedJobRegistry( job.origin, self.connection, job_class=self.job_class, serializer=self.serializer @@ -1548,9 +1548,9 @@ class Worker(BaseWorker): job.started_at = now() timeout = job.timeout or self.queue_class.DEFAULT_TIMEOUT with self.death_penalty_class(timeout, JobTimeoutException, job_id=job.id): - self.log.debug('Performing Job...') + self.log.debug('Performing Job %s ...', job.id) rv = job.perform() - self.log.debug('Finished performing Job ID %s', job.id) + self.log.debug('Finished performing Job %s', job.id) self.handle_execution_ended(job, queue, job.success_callback_timeout) # Pickle the result in the same try-except block since we need