celery.py 1.41 KB
Newer Older
Arnaud Fabre's avatar
Arnaud Fabre committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# coding: utf-8

# This file is part of memopol.
#
# memopol is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or any later version.
#
# memopol is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Affero Public
# License along with django-representatives.
# If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2015 Arnaud Fabre <af@laquadrature.net>

from __future__ import absolute_import

import os

Arnaud Fabre's avatar
Arnaud Fabre committed
25
26
from django.conf import settings

Arnaud Fabre's avatar
Arnaud Fabre committed
27
28
29
30
31
32
33
from celery import Celery

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

app = Celery(
    'memopol',
Arnaud Fabre's avatar
Arnaud Fabre committed
34
35
    broker='redis://localhost/{}'.format(settings.REDIS_DB),
    backend='redis://localhost/{}'.format(settings.REDIS_DB)
Arnaud Fabre's avatar
Arnaud Fabre committed
36
37
38
39
40
41
42
43
44
45
46
)

# Using a string here means the worker will not have to
# pickle the object when using Windows.
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))