torchbox / wagtail-template

A Django template for starting new Wagtail projects with Vagrant. NO LONGER MAINTANED
19 stars 8 forks source link

Add Celery #21

Closed zerolab closed 9 years ago

zerolab commented 9 years ago

We use it on most TBX projects, so worth adding it.

Celery 3.1+ integrates with Django out of the box, so no need for django-celery. See http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html

zerolab commented 9 years ago

Settings to add Relevant settings:

from .base import INSTALLED_APPS

INSTALLED_APPS += (
    'djcelery',
    'kombu.transport.django',
)

# CELERY SETTINGS
import djcelery
djcelery.setup_loader()

BROKER_URL = 'redis://'
CELERY_SEND_TASK_ERROR_EMAILS = True
CELERYD_LOG_COLOR = False

# Change default Celery queues
from kombu import Exchange, Queue
CELERY_DEFAULT_QUEUE = 'PROJECTPREFIX_celery'
CELERY_QUEUES = (
    Queue('PROJECTPREFIX_celery', Exchange('PROJECTPREFIX_celery'), routing_key='PROJECTPREFIX_celery'),
)

And a good article on working with Celery in python/Django: http://www.revsys.com/12days/async-workers-celery/