allow depends_on to be a job id or a job itself

Other parts of the code (i.e.: the `.create()` method) allow the `depends_on` kwarg to be a `Job` object *or* a job id. This is an attempt to allow that same idea within the `.enqueue_call()` method for a queue. Since this part of the code requires actually knowing the precise redis key for the job that's depended on, my intuition is that a `.fetch()` is the only way to solve this.
This commit is contained in:
Travis Johnson 2014-11-11 15:09:06 -05:00
parent 0dbe68527c
commit 3467868f1f
1 changed files with 2 additions and 0 deletions

View File

@ -189,6 +189,8 @@ class Queue(object):
# If WatchError is raised in the process, that means something else is
# modifying the dependency. In this case we simply retry
if depends_on is not None:
if not isinstance(depends_on, Job):
depends_on = Job.fetch(id=depends_on, connection=self.connection)
with self.connection.pipeline() as pipe:
while True:
try: