celery.py 711 B

1234567891011121314151617181920212223
  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", "glitchtip.settings")
  5. app = Celery("glitchtip")
  6. # Using a string here means the worker doesn't have to serialize
  7. # the configuration object to child processes.
  8. # - namespace='CELERY' means all celery-related configuration keys
  9. # should have a `CELERY_` prefix.
  10. app.config_from_object("django.conf:settings", namespace="CELERY")
  11. # Load task modules from all registered Django app configs.
  12. app.autodiscover_tasks()
  13. @app.task(bind=True)
  14. def debug_task(self):
  15. # pylint: disable=consider-using-f-string
  16. print("Request: {0!r}".format(self.request))