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.
main
Travis Johnson 10 years ago
parent 0dbe68527c
commit 3467868f1f

@ -189,6 +189,8 @@ class Queue(object):
# If WatchError is raised in the process, that means something else is # If WatchError is raised in the process, that means something else is
# modifying the dependency. In this case we simply retry # modifying the dependency. In this case we simply retry
if depends_on is not None: 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: with self.connection.pipeline() as pipe:
while True: while True:
try: try:

Loading…
Cancel
Save