Created
July 21, 2014 21:16
-
-
Save rizumu/98072fed1d10cd05ab23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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