Skip to content

Instantly share code, notes, and snippets.

@timothymugayi
Created May 11, 2020 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timothymugayi/ee205e37b3f394f4b4b7693439d758d7 to your computer and use it in GitHub Desktop.
Save timothymugayi/ee205e37b3f394f4b4b7693439d758d7 to your computer and use it in GitHub Desktop.
from __future__ import absolute_import
import os
from celery import Celery
# Below sets the default Django settings module for the 'celery' app.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_celery_site.settings')
# Celery() object contains Celery tasks and configurations.
app = Celery('django_celery_site')
# The defined namespace='CELERY' means all celery-related configuration keys will be loaded
# into celery and should start with a prefix CELERY_
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment