From af4b0436c1b3b397183a5a9d7b1d3f98e3f0fce0 Mon Sep 17 00:00:00 2001 From: Travis Johnson Date: Tue, 18 Nov 2014 12:09:14 -0500 Subject: [PATCH 1/2] instantiate a job instead of fetch this removes the need for the depended on job.id already being saved --- rq/queue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rq/queue.py b/rq/queue.py index ff5f860..7dfb0f8 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -190,7 +190,7 @@ class Queue(object): # modifying the dependency. In this case we simply retry if depends_on is not None: if not isinstance(depends_on, self.job_class): - depends_on = Job.fetch(id=depends_on, connection=self.connection) + depends_on = Job(id=depends_on, connection=self.connection) with self.connection.pipeline() as pipe: while True: try: From b14f739dfe888f9fd845a489c398cb5adcd58ab4 Mon Sep 17 00:00:00 2001 From: Travis Johnson Date: Tue, 18 Nov 2014 12:09:22 -0500 Subject: [PATCH 2/2] no need for that save anymore --- tests/test_queue.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_queue.py b/tests/test_queue.py index 8990e35..ed42204 100644 --- a/tests/test_queue.py +++ b/tests/test_queue.py @@ -355,9 +355,7 @@ class TestQueue(RQTestCase): def test_enqueue_job_with_dependency_by_id(self): """Enqueueing jobs should work as expected by id as well as job-objects.""" parent_job = Job.create(func=say_hello) - # We need to save the job for the ID to exist in redis - parent_job.save() - + q = Queue() q.enqueue_call(say_hello, depends_on=parent_job.id) self.assertEqual(q.job_ids, [])