celery.py 576 B

12345678910111213141516171819202122
  1. import os
  2. from celery import Celery
  3. # set the default Django settings module for the 'celery' program.
  4. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings')
  5. from django.conf import settings # noqa
  6. app = Celery('proj')
  7. # Using a string here means the worker does not have to serialize
  8. # the configuration object.
  9. app.config_from_object('django.conf:settings', namespace='CELERY')
  10. # load task modules from all registered Django app configs.
  11. app.autodiscover_tasks()
  12. @app.task(bind=True)
  13. def debug_task(self):
  14. print('Request: {0!r}'.format(self.request))