From 8a3fd91e2ec2bc09af30652f3ed9b8ce846d8922 Mon Sep 17 00:00:00 2001 From: glaslos Date: Wed, 26 Nov 2014 10:12:52 +0100 Subject: [PATCH] renaming job.job_ttl to job.ttl --- rq/job.py | 12 ++++++------ rq/queue.py | 8 ++++---- tests/test_job.py | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/rq/job.py b/rq/job.py index a026fda..865ca30 100644 --- a/rq/job.py +++ b/rq/job.py @@ -92,7 +92,7 @@ class Job(object): # Job construction @classmethod def create(cls, func, args=None, kwargs=None, connection=None, - result_ttl=None, job_ttl=None, status=None, description=None, depends_on=None, timeout=None, + result_ttl=None, ttl=None, status=None, description=None, depends_on=None, timeout=None, id=None): """Creates a new Job instance for the given function, arguments, and keyword arguments. @@ -131,7 +131,7 @@ class Job(object): # Extra meta data job.description = description or job.get_call_string() job.result_ttl = result_ttl - job.job_ttl = job_ttl + job.ttl = ttl job.timeout = timeout job._status = status @@ -312,7 +312,7 @@ class Job(object): self.exc_info = None self.timeout = None self.result_ttl = None - self.job_ttl = None + self.ttl = None self._status = None self._dependency_id = None self.meta = {} @@ -457,8 +457,8 @@ class Job(object): connection = pipeline if pipeline is not None else self.connection connection.hmset(key, self.to_dict()) - if self.job_ttl: - connection.expire(key, self.job_ttl) + if self.ttl: + connection.expire(key, self.ttl) def cancel(self): """Cancels the given job, which will prevent the job from ever being @@ -499,7 +499,7 @@ class Job(object): persisted. In the future, this method will also be responsible for determining ttl for repeated jobs. """ - return default_ttl if self.job_ttl is None else self.job_ttl + return default_ttl if self.ttl is None else self.ttl def get_result_ttl(self, default_ttl=None): """Returns ttl for a job that determines how long a jobs result will diff --git a/rq/queue.py b/rq/queue.py index 9a2c9af..ccd4e6b 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -167,7 +167,7 @@ class Queue(object): connection.rpush(self.key, job_id) def enqueue_call(self, func, args=None, kwargs=None, timeout=None, - result_ttl=None, job_ttl=None, description=None, + result_ttl=None, ttl=None, description=None, depends_on=None, job_id=None): """Creates a job to represent the delayed function call and enqueues it. @@ -180,7 +180,7 @@ class Queue(object): # TODO: job with dependency shouldn't have "queued" as status job = self.job_class.create(func, args, kwargs, connection=self.connection, - result_ttl=result_ttl, job_ttl=job_ttl, status=Status.QUEUED, + result_ttl=result_ttl, ttl=ttl, status=Status.QUEUED, description=description, depends_on=depends_on, timeout=timeout, id=job_id) @@ -229,7 +229,7 @@ class Queue(object): timeout = kwargs.pop('timeout', None) description = kwargs.pop('description', None) result_ttl = kwargs.pop('result_ttl', None) - job_ttl = kwargs.pop('job_ttl', None) + ttl = kwargs.pop('ttl', None) depends_on = kwargs.pop('depends_on', None) job_id = kwargs.pop('job_id', None) @@ -239,7 +239,7 @@ class Queue(object): kwargs = kwargs.pop('kwargs', None) return self.enqueue_call(func=f, args=args, kwargs=kwargs, - timeout=timeout, result_ttl=result_ttl, job_ttl=job_ttl, + timeout=timeout, result_ttl=result_ttl, ttl=ttl, description=description, depends_on=depends_on, job_id=job_id) diff --git a/tests/test_job.py b/tests/test_job.py index 27cebb0..34859a7 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -305,10 +305,10 @@ class TestJob(RQTestCase): def test_get_job_ttl(self): """Getting job TTL.""" - job_ttl = 1 - job = Job.create(func=say_hello, job_ttl=job_ttl) + ttl = 1 + job = Job.create(func=say_hello, ttl=ttl) job.save() - self.assertEqual(job.get_ttl(), job_ttl) + self.assertEqual(job.get_ttl(), ttl) job = Job.create(func=say_hello) job.save() self.assertEqual(job.get_ttl(), None)