Use result_ttl for synchronous queues (#1510)

This commit is contained in:
Bo Bayles 2021-07-19 04:21:27 -05:00 committed by GitHub
parent bc0b55fd92
commit adc03e8119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -448,7 +448,7 @@ nd
job.perform()
job.set_status(JobStatus.FINISHED)
job.save(include_meta=False)
job.cleanup(DEFAULT_RESULT_TTL)
job.cleanup(job.get_result_ttl(default_ttl=DEFAULT_RESULT_TTL))
return job
@classmethod

View File

@ -335,6 +335,18 @@ class TestQueue(RQTestCase):
job = queue.enqueue_job(job)
self.assertEqual(job.timeout, 15)
def test_synchronous_timeout(self):
queue = Queue(is_async=False)
no_expire_job = queue.enqueue(echo, result_ttl=-1)
self.assertEqual(queue.connection.ttl(no_expire_job.key), -1)
delete_job = queue.enqueue(echo, result_ttl=0)
self.assertEqual(queue.connection.ttl(delete_job.key), -2)
keep_job = queue.enqueue(echo, result_ttl=100)
self.assertLessEqual(queue.connection.ttl(keep_job.key), 100)
def test_enqueue_explicit_args(self):
"""enqueue() works for both implicit/explicit args."""
q = Queue()