diff --git a/rq/registry.py b/rq/registry.py index c59bf88..a1b89b2 100644 --- a/rq/registry.py +++ b/rq/registry.py @@ -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) diff --git a/tests/test_registry.py b/tests/test_registry.py index ce4a345..36b9792 100644 --- a/tests/test_registry.py +++ b/tests/test_registry.py @@ -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))