2015-11-20 64 views
1

我芹菜任务运行良好
但是我发现我djcelery_taskstate表有什么:
enter image description hereDjcelery:如何芹菜任务状态保存到数据库

如何可以将其数据保存到它?

这里是我的设置:

settings.py

BROKER_URL = 'redis://localhost:6379' 
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler' 
CELERY_RESULT_BACKEND = 'djcelery.backends.database:DatabaseBackend' 
CELERY_TIMEZONE = 'Asia/Taipei' 

celery.py

from __future__ import absolute_import 
import os 
from celery import Celery 

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings') 
from django.conf import settings # noqa 
app = Celery('myproject') 

app.config_from_object('django.conf:settings') 
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) 
app.conf.update(
    CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend', 
    CELERY_TIMEZONE = 'Asia/Taipei' 
) 

tasks.py

from __future__ import absolute_import 
from celery.task.schedules import crontab 
from celery.decorators import periodic_task 
from celery import task 
from datetime import timedelta 
from myapp.deal import check_data 


@periodic_task(run_every=timedelta(seconds=30),name="collect-rawdata",ignore_result=True) 
def rawdata(): 
    return check_data() 

在这里,我我的命令来运行芹菜:

一个终端运行:

celery -A wiarea worker -l info 

另一个运行:

celery -A wiarea beat -l info 

回答

0

您已设置ignore_result为True。这使得芹菜放弃了结果,并没有将它保存在任何地方。