parent
88d3aff6e9
commit
2c8a71eaa0
5 changed files with 37 additions and 34 deletions
@ -1,5 +1,7 @@ |
|||||||
# -*- coding: utf-8 -*- |
from __future__ import absolute_import, unicode_literals |
||||||
from __future__ import absolute_import |
|
||||||
# from .celery import app as celery_app |
# This will make sure the app is always imported when |
||||||
# |
# Django starts so that shared_task will use this app. |
||||||
# __all__ = ['celery_app'] |
from .celery import app as celery_app |
||||||
|
|
||||||
|
__all__ = ['celery_app'] |
||||||
|
|||||||
@ -1,23 +1,23 @@ |
|||||||
# -*- coding: utf-8 -*- |
|
||||||
from __future__ import absolute_import, unicode_literals |
from __future__ import absolute_import, unicode_literals |
||||||
import os |
import os |
||||||
|
from celery import Celery |
||||||
import celery |
|
||||||
print celery.__file__ |
|
||||||
# from celery import Celery |
|
||||||
from django.conf import settings |
|
||||||
|
|
||||||
# set the default Django settings module for the 'celery' program. |
# set the default Django settings module for the 'celery' program. |
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings') |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings') |
||||||
|
|
||||||
# app = Celery('proj') |
app = Celery('project') |
||||||
|
|
||||||
|
# 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() |
||||||
|
|
||||||
# Using a string here means the worker will not have to |
|
||||||
# pickle the object when using Windows. |
|
||||||
# app.config_from_object('django.conf:settings') |
|
||||||
# app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) |
|
||||||
|
|
||||||
|
@app.task(bind=True) |
||||||
|
def debug_task(self): |
||||||
|
print('Request: {0!r}'.format(self.request)) |
||||||
|
|
||||||
# @app.task(bind=True) |
|
||||||
# def debug_task(self): |
|
||||||
# print('Request: {0!r}'.format(self.request)) |
|
||||||
Loading…
Reference in new issue