我的django设置中有以下设置:
CELERY_TASK_RESULT_EXPIRES = timedelta(minutes=30)
CELERY_CHORD_PROPAGATES = True
CELERY_ACCEPT_CONTENT = ['json', 'msgpack', 'yaml']
CELERY_ALWAYS_EAGER = True
CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
BROKER_URL = 'django://'
CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend'
我已在我已安装的应用程序下包含以下内容:
^{pr2}$我的项目结构是(django 1.5)
proj
|_proj
__init__.py
celery.py
|_apps
|_myapp1
|_models.py
|_tasks.py
这是我的celery.py
文件:
from __future__ import absolute_import
import os
from celery import Celery
from django.conf import settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings.dev')
app = Celery('proj')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, related_name='tasks')
在主__init__.py
中,我有:
from __future__ import absolute_import
from .celery import app as celery_app
最后在myapp1/任务.py我定义我的任务:
@task()
def retrieve():
# Do my stuff
现在,如果我启动一个django交互式shell并启动retrieve
任务:
result = retrieve.delay()
它似乎总是一个阻塞的调用,这意味着在函数返回之前提示被阻塞。result
状态为SUCCESS,该函数实际执行操作,但似乎不是异步的。我错过了什么?在
似乎是CELERY_ALWAYS_EAGER造成的
相关问题 更多 >
编程相关推荐