Add support for overriding the celery class.
This commit is contained in:
@@ -2,12 +2,13 @@ from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from celery import Celery
|
||||
from django.conf import settings
|
||||
|
||||
from .runtime import celery_class
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mayan.settings.production')
|
||||
|
||||
app = Celery('mayan')
|
||||
app = celery_class('mayan')
|
||||
|
||||
app.config_from_object('django.conf:settings')
|
||||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
||||
|
||||
18
mayan/conf.py
Normal file
18
mayan/conf.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""
|
||||
This module should be called settings.py but is named conf.py to avoid a
|
||||
class with the mayan/settings/* module
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from smart_settings import Namespace
|
||||
|
||||
namespace = Namespace(name='mayan', label=_('Mayan'))
|
||||
|
||||
setting_celery_class = namespace.add_setting(
|
||||
help_text=_('The class used to instanciate the main Celery app.'),
|
||||
global_name='MAYAN_CELERY_CLASS',
|
||||
default='celery.Celery'
|
||||
)
|
||||
5
mayan/runtime.py
Normal file
5
mayan/runtime.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.utils.module_loading import import_string
|
||||
|
||||
from .conf import setting_celery_class
|
||||
|
||||
celery_class = import_string(setting_celery_class.value)
|
||||
Reference in New Issue
Block a user