From 44818b983a7fdc07650eedcea19032c72492057c Mon Sep 17 00:00:00 2001 From: aditya Date: Thu, 21 May 2020 11:57:51 +0530 Subject: Rename celery.py to celery_settings and change imports --- online_test/__init__.py | 4 +--- online_test/celery.py | 25 ------------------------- online_test/celery_settings.py | 23 +++++++++++++++++++++++ 3 files changed, 24 insertions(+), 28 deletions(-) delete mode 100644 online_test/celery.py create mode 100644 online_test/celery_settings.py diff --git a/online_test/__init__.py b/online_test/__init__.py index 642bfd0..c050823 100644 --- a/online_test/__init__.py +++ b/online_test/__init__.py @@ -1,6 +1,4 @@ -from __future__ import absolute_import, unicode_literals - -from online_test.celery import app as celery_app +from .celery_settings import app as celery_app __all__ = ('celery_app',) diff --git a/online_test/celery.py b/online_test/celery.py deleted file mode 100644 index 6868b89..0000000 --- a/online_test/celery.py +++ /dev/null @@ -1,25 +0,0 @@ -from __future__ import absolute_import, unicode_literals - -import os -from django.conf import settings -from celery import Celery - -# set the default Django settings module for the 'celery' program. -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'online_test.settings') - -app = Celery('online_test') - -# 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(lambda: settings.INSTALLED_APPS) - -@app.task(name='celery.ping') -def ping(): - # type: () -> str - """Simple task that just returns 'pong'.""" - return 'pong' diff --git a/online_test/celery_settings.py b/online_test/celery_settings.py new file mode 100644 index 0000000..059bb87 --- /dev/null +++ b/online_test/celery_settings.py @@ -0,0 +1,23 @@ +import os +from django.conf import settings +from celery import Celery + +# set the default Django settings module for the 'celery' program. +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'online_test.settings') + +app = Celery('online_test') + +# 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(lambda: settings.INSTALLED_APPS) + +@app.task(name='celery.ping') +def ping(): + # type: () -> str + """Simple task that just returns 'pong'.""" + return 'pong' -- cgit