use new celery

This commit is contained in:
j 2019-07-16 12:22:22 +01:00
commit 46621522b1
4 changed files with 31 additions and 6 deletions

20
pandora/celery.py Normal file
View file

@ -0,0 +1,20 @@
import os
from celery import Celery
root_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
os.chdir(root_dir)
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
app = Celery('pandora')
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()

View file

@ -195,7 +195,7 @@ DATABASES = {
}
#rabbitmq connection settings
CELERY_RESULT_BACKEND = 'database'
CELERY_RESULT_BACKEND = 'django-db'
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT = ['json']
@ -297,3 +297,8 @@ ALLOWED_HOSTS = ['*']
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
DATA_UPLOAD_MAX_MEMORY_SIZE = 32 * 1024 * 1024
try:
CELERY_BROKER_URL
except NameError:
CELERY_BROKER_URL = BROKER_URL