|
@@ -297,9 +297,9 @@ Say you have two servers, ``x``, and ``y`` that handles regular tasks,
|
|
|
and one server ``z``, that only handles feed related tasks, you can use this
|
|
|
configuration:
|
|
|
|
|
|
- * Servers ``x`` and ``y``: settings.py:
|
|
|
+* Servers ``x`` and ``y``: settings.py:
|
|
|
|
|
|
- .. code-block:: python
|
|
|
+.. code-block:: python
|
|
|
|
|
|
CELERY_DEFAULT_QUEUE = "regular_tasks"
|
|
|
CELERY_QUEUES = {
|
|
@@ -307,13 +307,13 @@ configuration:
|
|
|
"binding_key": "task.#",
|
|
|
},
|
|
|
}
|
|
|
- CELERY_DEFAULT_EXCHANGE = "tasks"
|
|
|
- CELERY_DEFAULT_EXCHANGE_TYPE = "topic"
|
|
|
- CELERY_DEFAULT_ROUTING_KEY = "task.regular"
|
|
|
+ CELERY_DEFAULT_EXCHANGE = "tasks"
|
|
|
+ CELERY_DEFAULT_EXCHANGE_TYPE = "topic"
|
|
|
+ CELERY_DEFAULT_ROUTING_KEY = "task.regular"
|
|
|
|
|
|
- * Server ``z``: settings.py:
|
|
|
+* Server ``z``: settings.py:
|
|
|
|
|
|
- .. code-block:: python
|
|
|
+.. code-block:: python
|
|
|
|
|
|
CELERY_DEFAULT_QUEUE = "feed_tasks"
|
|
|
CELERY_QUEUES = {
|
|
@@ -335,13 +335,20 @@ Now to make a Task run on the ``z`` server you need to set its
|
|
|
.. code-block:: python
|
|
|
|
|
|
from feedaggregator.models import Feed
|
|
|
- from celery.task import Task
|
|
|
+ from celery.decorators import task
|
|
|
+
|
|
|
+ @task(routing_key="feed.importer")
|
|
|
+ def import_feed(feed_url):
|
|
|
+ Feed.objects.import_feed(feed_url)
|
|
|
+
|
|
|
+or if subclassing the ``Task`` class directly:
|
|
|
+
|
|
|
+.. code-block:: python
|
|
|
|
|
|
class FeedImportTask(Task):
|
|
|
routing_key = "feed.importer"
|
|
|
|
|
|
def run(self, feed_url):
|
|
|
- # something importing the feed
|
|
|
Feed.objects.import_feed(feed_url)
|
|
|
|
|
|
|
|
@@ -376,7 +383,7 @@ just specify a custom exchange and exchange type:
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
-CELERY_QUEUES = {
|
|
|
+ CELERY_QUEUES = {
|
|
|
"feed_tasks": {
|
|
|
"binding_key": "feed.#",
|
|
|
},
|