Call move_expired_jobs_to_failed_queue before returning job_ids.

main
Selwin Ong 10 years ago
parent dc12f8aee5
commit 6d79082b62

@ -40,11 +40,12 @@ class StartedJobRegistry:
def get_job_ids(self, start=0, end=-1): def get_job_ids(self, start=0, end=-1):
"""Returns list of all job ids.""" """Returns list of all job ids."""
self.move_expired_jobs_to_failed_queue()
return [as_text(job_id) for job_id in return [as_text(job_id) for job_id in
self.connection.zrange(self.key, start, end)] self.connection.zrange(self.key, start, end)]
def cleanup(self): def move_expired_jobs_to_failed_queue(self):
"""Removes expired job ids to FailedQueue.""" """Remove expired jobs from registry and add them to FailedQueue."""
job_ids = self.get_expired_job_ids() job_ids = self.get_expired_job_ids()
if job_ids: if job_ids:

@ -51,7 +51,7 @@ class TestQueue(RQTestCase):
failed_queue = FailedQueue(connection=self.testconn) failed_queue = FailedQueue(connection=self.testconn)
self.assertTrue(failed_queue.is_empty()) self.assertTrue(failed_queue.is_empty())
self.testconn.zadd(self.registry.key, 1, 'foo') 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) self.assertIn('foo', failed_queue.job_ids)
def test_job_execution(self): def test_job_execution(self):

Loading…
Cancel
Save