celery.py 568 B

12345678910111213141516171819202122
  1. from __future__ import absolute_import
  2. import os
  3. from celery import Celery
  4. # set the default Django settings module for the 'celery' program.
  5. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings')
  6. from django.conf import settings # noqa
  7. app = Celery('proj')
  8. # Using a string here means the worker will not have to
  9. # pickle the object when using Windows.
  10. app.config_from_object('django.conf:settings')
  11. app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
  12. @app.task(bind=True)
  13. def debug_task(self):
  14. print('Request: {0!r}'.format(self.request))