我需要排队芹菜应将任务执行结果的配置,我正在使用文档中所述的方式(item" reply_to"):
@app.task(reply_to='export_task') # <= configured right way
def test_func():
return "here is result of task"
预期行为
任务结果应在队列中,名称为" export_task"(在装饰器中配置)
实际行为
任务结果位于队列中,名称为:D5587446-0149-3133-A3ED-D9A297D52A96
芹菜报告:
python -m celery -A my_worker report
software -> celery:3.1.24 (Cipater) kombu:3.0.37 py:3.5.1
billiard:3.3.0.23 py-amqp:1.4.9
platform -> system:Windows arch:64bit, WindowsPE imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:amqp results:rpc:///
CELERY_ACCEPT_CONTENT: ['json']
CELERY_RESULT_BACKEND: 'rpc:///'
CELERY_QUEUES:
(<unbound Queue main_check -> <unbound Exchange main_check(direct)> -> main_check>,)
CELERYD_CONCURRENCY: 10
CELERY_TASK_SERIALIZER: 'json'
CELERY_RESULT_PERSISTENT: True
CELERY_ROUTES: {
'my_worker.test_func': {'queue': 'main_check'}}
BROKER_TRANSPORT: 'amqp'
CELERYD_MAX_TASKS_PER_CHILD: 3
CELERY_RESULT_SERIALIZER: 'json'
重现的步骤
请创建项目的文件。
celery_app.py :
from celery import Celery
from kombu import Exchange, Queue
app = Celery('worker')
app.conf.update(
CELERY_ROUTES={
'my_worker.test_func': {'queue': 'main_check'},
},
BROKER_TRANSPORT='amqp',
CELERY_RESULT_BACKEND='rpc://',
CELERY_RESULT_PERSISTENT=True,
# CELERY_DEFAULT_DELIVERY_MODE='persistent',
# CELERY_RESULT_EXCHANGE='export_task',
CELERYD_CONCURRENCY=10,
CELERYD_MAX_TASKS_PER_CHILD=3,
CELERY_TASK_SERIALIZER='json',
CELERY_RESULT_SERIALIZER='json',
CELERY_ACCEPT_CONTENT=['json'],
CELERY_QUEUES=(
Queue('main_check', Exchange('main_check', type='direct'), routing_key='main_check'),
),
)
my_worker.py:
from celery_app import app
@app.task(reply_to='export_task')
def test_func():
return "here is result of task"
然后开始芹菜:
python -m celery -A my_worker worker --loglevel=info
然后在Python调试控制台中添加新任务:
from my_worker import *
result = test_func.delay()
我要求在官方发行跟踪器上提供帮助,但没人在乎。
我在您的代码中看不到该队列(export_task)已声明。