Ensure the FinishedJobRegistry honors an 'infinite' result_ttl of -1

main
Nic Cope 10 years ago
parent 786d3c5887
commit 8fa184b86b

@ -28,8 +28,8 @@ class BaseRegistry(object):
return self.connection.zcard(self.key)
def add(self, job, timeout, pipeline=None):
"""Adds a job to StartedJobRegistry with expiry time of now + timeout."""
score = current_timestamp() + timeout
"""Adds a job to a registry with expiry time of now + timeout."""
score = timeout if timeout == -1 else current_timestamp() + timeout
if pipeline is not None:
return pipeline.zadd(self.key, score, job.id)

@ -27,6 +27,10 @@ class TestRegistry(RQTestCase):
self.assertLess(self.testconn.zscore(self.registry.key, job.id),
timestamp + 1002)
# Ensure that a timeout of -1 results in a score of -1
self.registry.add(job, -1)
self.assertEqual(self.testconn.zscore(self.registry.key, job.id), -1)
# Ensure that job is properly removed from sorted set
self.registry.remove(job)
self.assertIsNone(self.testconn.zscore(self.registry.key, job.id))

Loading…
Cancel
Save