From 6d79082b62ac5b2af48d2a91618e31c07ca3768c Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Mon, 8 Sep 2014 23:04:18 +0700 Subject: [PATCH] Call move_expired_jobs_to_failed_queue before returning job_ids. --- rq/registry.py | 5 +++-- tests/test_job_started_registry.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rq/registry.py b/rq/registry.py index 2bf1445..afa7b5b 100644 --- a/rq/registry.py +++ b/rq/registry.py @@ -40,11 +40,12 @@ class StartedJobRegistry: def get_job_ids(self, start=0, end=-1): """Returns list of all job ids.""" + self.move_expired_jobs_to_failed_queue() return [as_text(job_id) for job_id in self.connection.zrange(self.key, start, end)] - def cleanup(self): - """Removes expired job ids to FailedQueue.""" + def move_expired_jobs_to_failed_queue(self): + """Remove expired jobs from registry and add them to FailedQueue.""" job_ids = self.get_expired_job_ids() if job_ids: diff --git a/tests/test_job_started_registry.py b/tests/test_job_started_registry.py index e8241b5..addb1db 100644 --- a/tests/test_job_started_registry.py +++ b/tests/test_job_started_registry.py @@ -51,7 +51,7 @@ class TestQueue(RQTestCase): failed_queue = FailedQueue(connection=self.testconn) self.assertTrue(failed_queue.is_empty()) self.testconn.zadd(self.registry.key, 1, 'foo') - self.registry.cleanup() + self.registry.move_expired_jobs_to_failed_queue() self.assertIn('foo', failed_queue.job_ids) def test_job_execution(self):