add celery basics

This commit is contained in:
Laura Klünder 2016-09-27 15:32:42 +02:00
parent 78fc67ebdb
commit e8c1e7006c
4 changed files with 24 additions and 1 deletions

View file

@ -1,3 +1,3 @@
[settings]
line_length=120
skip=migrations
skip=migrations,celery.py

11
src/c3nav/celery.py Normal file
View file

@ -0,0 +1,11 @@
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'c3nav.settings')
from django.conf import settings # noqa
app = Celery('c3nav')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

View file

@ -101,6 +101,17 @@ if HAS_MEMCACHED:
}
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
HAS_CELERY_BROKER = config.has_option('celery', 'broker')
if HAS_CELERY_BROKER:
BROKER_URL = config.get('celery', 'broker')
CELERY_RESULT_BACKEND = config.get('celery', 'backend')
CELERY_SEND_TASK_ERROR_EMAILS = bool(ADMINS)
else:
CELERY_ALWAYS_EAGER = True
CELERY_TASK_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_RESULT_SERIALIZER = 'json'
SESSION_COOKIE_DOMAIN = config.get('c3nav', 'cookie_domain', fallback=None)
SESSION_COOKIE_SECURE = config.getboolean('c3nav', 'session_cookie_secure', fallback=False)

View file

@ -5,3 +5,4 @@ csscompressor
djangorestframework>=3.4,<3.5
django-filter>=0.14,<0.15
shapely>=1.5,<1.6
celery>=3.1,<3.2