mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-08 07:48:11 +08:00
Merge pull request #140 from Koed00/dev
Adds poll option for database brokers
This commit is contained in:
@@ -61,7 +61,7 @@ class Mongo(Broker):
|
|||||||
if task:
|
if task:
|
||||||
return [(str(task['_id']), task['payload'])]
|
return [(str(task['_id']), task['payload'])]
|
||||||
# empty queue, spare the cpu
|
# empty queue, spare the cpu
|
||||||
sleep(0.2)
|
sleep(Conf.POLL)
|
||||||
|
|
||||||
def delete_queue(self):
|
def delete_queue(self):
|
||||||
return self.collection.drop()
|
return self.collection.drop()
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class ORM(Broker):
|
|||||||
task_list.append((task.pk, task.payload))
|
task_list.append((task.pk, task.payload))
|
||||||
return task_list
|
return task_list
|
||||||
# empty queue, spare the cpu
|
# empty queue, spare the cpu
|
||||||
sleep(0.2)
|
sleep(Conf.POLL)
|
||||||
|
|
||||||
def delete_queue(self):
|
def delete_queue(self):
|
||||||
return self.purge_queue()
|
return self.purge_queue()
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ class Conf(object):
|
|||||||
# ORM broker
|
# ORM broker
|
||||||
ORM = conf.get('orm', None)
|
ORM = conf.get('orm', None)
|
||||||
|
|
||||||
|
# Database Poll
|
||||||
|
POLL = conf.get('poll', 0.2)
|
||||||
|
|
||||||
# MongoDB broker
|
# MongoDB broker
|
||||||
MONGO = conf.get('mongo', None)
|
MONGO = conf.get('mongo', None)
|
||||||
MONGO_DB = conf.get('mongo_db', None)
|
MONGO_DB = conf.get('mongo_db', None)
|
||||||
|
|||||||
@@ -303,6 +303,11 @@ Keep in mind however that settings this too high can degrade performance with mu
|
|||||||
Not supported by the default Redis broker.
|
Not supported by the default Redis broker.
|
||||||
Defaults to ``1``.
|
Defaults to ``1``.
|
||||||
|
|
||||||
|
poll
|
||||||
|
~~~~
|
||||||
|
Sets the queue polling interval for database brokers that don't have a blocking call. Defaults to 0.2 (seconds).
|
||||||
|
Currently only affects the ORM and MongoDB brokers.
|
||||||
|
|
||||||
cache
|
cache
|
||||||
~~~~~
|
~~~~~
|
||||||
For some brokers, you will need to set up the Django `cache framework <https://docs.djangoproject.com/en/1.8/topics/cache/#setting-up-the-cache>`__
|
For some brokers, you will need to set up the Django `cache framework <https://docs.djangoproject.com/en/1.8/topics/cache/#setting-up-the-cache>`__
|
||||||
|
|||||||
Reference in New Issue
Block a user