dev_with_worker.py 1.15 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
"""
This config file follows the dev enviroment, but adds the
requirement of a celery worker running in the background to process
celery tasks.

The worker can be executed using:

django_admin.py celery worker
"""

11 12
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
13
# pylint: disable=wildcard-import, unused-wildcard-import
14

15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
from dev import *

################################# CELERY ######################################

# Requires a separate celery worker

CELERY_ALWAYS_EAGER = False

# Use django db as the broker and result store

BROKER_URL = 'django://'
INSTALLED_APPS += ('djcelery.transport', )
CELERY_RESULT_BACKEND = 'database'
DJKOMBU_POLLING_INTERVAL = 1.0

# Disable transaction management because we are using a worker. Views
# that request a task and wait for the result will deadlock otherwise.

MIDDLEWARE_CLASSES = tuple(
    c for c in MIDDLEWARE_CLASSES
    if c != 'django.middleware.transaction.TransactionMiddleware')

# Note: other alternatives for disabling transactions don't work in 1.4
# https://code.djangoproject.com/ticket/2304
# https://code.djangoproject.com/ticket/16039