mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-03 02:28:12 +08:00
Merge pull request #69 from Koed00/dev
docs: Replaced redis pooling with broker pooling example.
This commit is contained in:
@@ -8,6 +8,7 @@ from .tasks import async, schedule, result, result_group, fetch, fetch_group, co
|
|||||||
from .models import Task, Schedule, Success, Failure
|
from .models import Task, Schedule, Success, Failure
|
||||||
from .cluster import Cluster
|
from .cluster import Cluster
|
||||||
from .status import Stat
|
from .status import Stat
|
||||||
|
from .brokers import get_broker
|
||||||
|
|
||||||
VERSION = (0, 7, 3)
|
VERSION = (0, 7, 3)
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -59,9 +59,9 @@ sync
|
|||||||
Simulates a task execution synchronously. Useful for testing.
|
Simulates a task execution synchronously. Useful for testing.
|
||||||
Can also be forced globally via the :ref:`sync` configuration option.
|
Can also be forced globally via the :ref:`sync` configuration option.
|
||||||
|
|
||||||
redis
|
broker
|
||||||
"""""
|
""""""
|
||||||
A redis connection. In case you want to control your own connections.
|
A broker instance, in case you want to control your own connections.
|
||||||
|
|
||||||
q_options
|
q_options
|
||||||
"""""""""
|
"""""""""
|
||||||
@@ -173,17 +173,17 @@ Instead of setting ``sync`` on each individual ``async`` you can also configure
|
|||||||
Connection pooling
|
Connection pooling
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
Django Q tries to pass redis connections around its parts as much as possible to save you from running out of connections.
|
Django Q tries to pass broker instances around its parts as much as possible to save you from running out of connections.
|
||||||
When you are making individual calls to :func:`async` a lot though, it can help to set up a redis connection to reuse for :func:`async`:
|
When you are making individual calls to :func:`async` a lot though, it can help to set up a broker to reuse for :func:`async`:
|
||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
# redis connection economy example
|
# broker connection economy example
|
||||||
from django_q import async
|
from django_q import async, get_broker
|
||||||
from django_q.conf import redis_client
|
|
||||||
|
|
||||||
|
broker = get_broker()
|
||||||
for i in range(50):
|
for i in range(50):
|
||||||
async('math.modf', 2.5, redis=redis_client)
|
async('math.modf', 2.5, broker=broker)
|
||||||
|
|
||||||
.. tip::
|
.. tip::
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user