Moves bulk iteration to pusher

This commit is contained in:
Ilan Steemers
2015-09-15 14:45:06 +02:00
parent 9b7c76b9d3
commit a060b3508a
8 changed files with 39 additions and 73 deletions
+1 -9
View File
@@ -9,18 +9,10 @@ class IronMQBroker(Broker):
return self.connection.post(task)['ids'][0]
def dequeue(self):
t = None
if len(self.task_cache) > 0:
t = self.task_cache.pop()
else:
timeout = Conf.RETRY or None
tasks = self.connection.get(timeout=timeout, wait=1, max=Conf.BULK)['messages']
if tasks:
t = tasks.pop()
if tasks:
self.task_cache = tasks
if t:
return t['id'], t['body']
return [(t['id'], t['body']) for t in tasks]
def ping(self):
return self.connection.name == self.list_key