from __future__ import absolute_import, unicode_literals

import os

from celery import Celery

# set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")

app = Celery("app")

# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
#   should have a `CELERY_` prefix.
app.config_from_object("django.conf:settings", namespace="CELERY")

# Load task modules from all registered Django app configs.
app.autodiscover_tasks()

app.conf.update(
    task_serializer="json",
    accept_content=["json"],  # Ignore other content
    result_serializer="json",
    timezone="Europe/Oslo",
    enable_utc=True,
)


@app.task(bind=True)
def debug_task(self):
    print("Request: {0!r}".format(self.request))

[((8, 0, 8, 63), 'os.environ.setdefault', 'os.environ.setdefault', ({(8, 22, 8, 46): '"""DJANGO_SETTINGS_MODULE"""', (8, 48, 8, 62): '"""app.settings"""'}, {}), "('DJANGO_SETTINGS_MODULE', 'app.settings')", False, 'import os\n'), ((10, 6, 10, 19), 'celery.Celery', 'Celery', ({(10, 13, 10, 18): '"""app"""'}, {}), "('app')", False, 'from celery import Celery\n')]