Skip to content

Instantly share code, notes, and snippets.

@rizumu
Created July 21, 2014 21:16
Show Gist options
  • Save rizumu/98072fed1d10cd05ab23 to your computer and use it in GitHub Desktop.
Save rizumu/98072fed1d10cd05ab23 to your computer and use it in GitHub Desktop.
import os
import envdir
from pathlib import Path
from celery import Celery
from django.conf import settings
from configurations import importer
parent = Path(__file__).resolve().parent.parent
path = parent / "envs" / os.environ.get("ENVDIR", "dev")
envdir.read(str(path))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "scenemachine.settings")
os.environ.setdefault("DJANGO_CONFIGURATION", "Dev")
# http://django-configurations.readthedocs.org/en/latest/cookbook/#celery
if not importer.installed:
importer.install()
app = Celery("scenemachine")
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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment