diff --git a/rq/job.py b/rq/job.py index ea25269..b3800a5 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 3eea3fb..7129452 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'))