Merge pull request #573 from jcsaaddupuy/feature/dequeue_any_not_recursive

dequeue_any not recursive
main
Selwin Ong 9 years ago
commit f09be523dd

@ -367,25 +367,27 @@ class Queue(object):
See the documentation of cls.lpop for the interpretation of timeout. See the documentation of cls.lpop for the interpretation of timeout.
""" """
queue_keys = [q.key for q in queues] while True:
result = cls.lpop(queue_keys, timeout, connection=connection) queue_keys = [q.key for q in queues]
if result is None: result = cls.lpop(queue_keys, timeout, connection=connection)
return None if result is None:
queue_key, job_id = map(as_text, result) return None
queue = cls.from_queue_key(queue_key, connection=connection) queue_key, job_id = map(as_text, result)
try: queue = cls.from_queue_key(queue_key, connection=connection)
job = cls.job_class.fetch(job_id, connection=connection) try:
except NoSuchJobError: job = cls.job_class.fetch(job_id, connection=connection)
# Silently pass on jobs that don't exist (anymore), except NoSuchJobError:
# and continue by reinvoking the same function recursively # Silently pass on jobs that don't exist (anymore),
return cls.dequeue_any(queues, timeout, connection=connection) # and continue in the look
except UnpickleError as e: continue
# Attach queue information on the exception for improved error except UnpickleError as e:
# reporting # Attach queue information on the exception for improved error
e.job_id = job_id # reporting
e.queue = queue e.job_id = job_id
raise e e.queue = queue
return job, queue raise e
return job, queue
return None, None
# Total ordering defition (the rest of the required Python methods are # Total ordering defition (the rest of the required Python methods are
# auto-generated by the @total_ordering decorator) # auto-generated by the @total_ordering decorator)

Loading…
Cancel
Save