From 09697e567f18590e31f8faad3c2f71e7b2f41659 Mon Sep 17 00:00:00 2001 From: Alexey Katichev Date: Mon, 22 May 2017 14:31:22 +0300 Subject: [PATCH] revert back job.cleanup changes --- rq/job.py | 7 ++----- tests/test_queue.py | 5 +++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/rq/job.py b/rq/job.py index ea252695..b3800a50 100644 --- a/rq/job.py +++ b/rq/job.py @@ -606,12 +606,9 @@ class Job(object): self.delete(pipeline=pipeline, remove_from_queue=remove_from_queue) elif not ttl: return - else: + elif ttl > 0: connection = pipeline if pipeline is not None else self.connection - if ttl > 0: - connection.expire(self.key, ttl) - else: - connection.persist(self.key) + connection.expire(self.key, ttl) def register_dependency(self, pipeline=None): """Jobs may have dependencies. Jobs are enqueued only if the job they diff --git a/tests/test_queue.py b/tests/test_queue.py index 3eea3fbd..7129452f 100644 --- a/tests/test_queue.py +++ b/tests/test_queue.py @@ -654,9 +654,10 @@ class TestFailedQueue(RQTestCase): def test_job_in_failed_queue_persists(self): """Make sure failed job key does not expire""" q = Queue('foo') - job = q.enqueue(div_by_zero, args=(1, 2, 3), ttl=5) + job = q.enqueue(div_by_zero, args=(1,), ttl=5) self.assertEqual(self.testconn.ttl(job.key), 5) - + + self.assertRaises(ZeroDivisionError, job.perform) job.set_status(JobStatus.FAILED) failed_queue = get_failed_queue() failed_queue.quarantine(job, Exception('Some fake error'))