2015-11-20 109 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。這使得芹菜放棄了結果,並沒有將它保存在任何地方。