From 78e522b1fa57fec7e99c05d01fe4bbf1fd04457c Mon Sep 17 00:00:00 2001 From: Stepan Krapivin Date: Thu, 9 Nov 2017 19:51:26 +0500 Subject: [PATCH] update celery --- .gitignore | 1 + batiskaf/__init__.py | 7 +++++++ batiskaf/celery.py | 2 +- dtys/tasks.py | 6 +++--- start_celery.sh | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index e1666db..d23ff42 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ static/cache/* .sass-cache local_* *.log +/static/dtys_update diff --git a/batiskaf/__init__.py b/batiskaf/__init__.py index e69de29..3b91b07 100644 --- a/batiskaf/__init__.py +++ b/batiskaf/__init__.py @@ -0,0 +1,7 @@ +from __future__ import absolute_import, unicode_literals + +# This will make sure the app is always imported when +# Django starts so that shared_task will use this app. +from .celery import app as celery_app + +__all__ = ['celery_app'] diff --git a/batiskaf/celery.py b/batiskaf/celery.py index 1f638f6..e3370b3 100644 --- a/batiskaf/celery.py +++ b/batiskaf/celery.py @@ -9,7 +9,7 @@ from django.conf import settings # set the default Django settings module for the 'celery' program. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'batiskaf.settings') -app = Celery('batiskaf') +app = Celery('batiskaf', broker='redis://localhost:6379/0') # Using a string here means the worker will not have to # pickle the object when using Windows. diff --git a/dtys/tasks.py b/dtys/tasks.py index cb93b4a..92680cd 100644 --- a/dtys/tasks.py +++ b/dtys/tasks.py @@ -1,9 +1,9 @@ -from celery import Celery +from celery import task -app = Celery('tasks', broker='redis://localhost:6379/0') +# app = Celery('tasks', broker='redis://localhost:6379/0') -@app.task +@task def return_dtys(dtys_id): from .models import DTYSModel diff --git a/start_celery.sh b/start_celery.sh index 00ef45e..7fa25e5 100755 --- a/start_celery.sh +++ b/start_celery.sh @@ -1,3 +1,3 @@ #!/bin/bash -celery -A dtys.tasks worker --loglevel=info >> celery.log & +celery -A batiskaf worker --loglevel=info >> celery.log &