mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-09 04:18:11 +08:00
Adds bulk option to disque broker
adds tests
This commit is contained in:
@@ -11,9 +11,18 @@ class Disque(Broker):
|
||||
'ADDJOB {} {} 500 RETRY {}'.format(self.list_key, task, retry)).decode()
|
||||
|
||||
def dequeue(self):
|
||||
task = self.connection.execute_command('GETJOB TIMEOUT 1000 FROM {}'.format(self.list_key))
|
||||
if task:
|
||||
return task[0][1].decode(), task[0][2].decode()
|
||||
t = None
|
||||
if len(self.task_cache) > 0:
|
||||
t = self.task_cache.pop()
|
||||
else:
|
||||
tasks = self.connection.execute_command(
|
||||
'GETJOB COUNT {} TIMEOUT 1000 FROM {}'.format(Conf.BULK, self.list_key))
|
||||
if tasks:
|
||||
t = tasks.pop()
|
||||
if tasks:
|
||||
self.task_cache = tasks
|
||||
if t:
|
||||
return t[1].decode(), t[2].decode()
|
||||
|
||||
def queue_size(self):
|
||||
return self.connection.execute_command('QLEN {}'.format(self.list_key))
|
||||
|
||||
Reference in New Issue
Block a user