mirror of https://github.com/rq/rq.git
Use result_ttl for synchronous queues (#1510)
This commit is contained in:
parent
bc0b55fd92
commit
adc03e8119
|
@ -448,7 +448,7 @@ nd
|
||||||
job.perform()
|
job.perform()
|
||||||
job.set_status(JobStatus.FINISHED)
|
job.set_status(JobStatus.FINISHED)
|
||||||
job.save(include_meta=False)
|
job.save(include_meta=False)
|
||||||
job.cleanup(DEFAULT_RESULT_TTL)
|
job.cleanup(job.get_result_ttl(default_ttl=DEFAULT_RESULT_TTL))
|
||||||
return job
|
return job
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -335,6 +335,18 @@ class TestQueue(RQTestCase):
|
||||||
job = queue.enqueue_job(job)
|
job = queue.enqueue_job(job)
|
||||||
self.assertEqual(job.timeout, 15)
|
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):
|
def test_enqueue_explicit_args(self):
|
||||||
"""enqueue() works for both implicit/explicit args."""
|
"""enqueue() works for both implicit/explicit args."""
|
||||||
q = Queue()
|
q = Queue()
|
||||||
|
|
Loading…
Reference in New Issue