“未知任务"发布新任务时芹菜花中的错误 [英] "Unknown task" error in Celery Flower when posting a new task
问题描述
我正在运行芹菜3.1.11和花0.6.0.
I'm running celery 3.1.11 and flower 0.6.0 .
我有这样配置的celery应用程序;
I have a celery application configured as such;
# myapp.tasks.celery.py
from __future__ import absolute_import
from celery import Celery
class Config(object):
BROKER_URL = 'amqp://'
CELERY_RESULT_BACKEND = 'amqp'
CELERY_TASK_RESULT_EXPIRES = None
CELERY_RESULT_SERIALIZER = 'json'
CELERY_INCLUDE = [
'myapp.tasks.source',
'myapp.tasks.page',
'myapp.tasks.diffusion',
'myapp.tasks.place',
]
)
celery = Celery('myapp')
celery.config_from_object(Config)
if __name__ == '__main__':
celery.start()
我使用以下命令执行芹菜工人:
I execute the celery worker using the following command:
$ celery -A myapp.tasks worker --loglevel=INFO -E -Q celery
我可以在worker输出中看到可用任务的完整列表.
I can see the complete list of available tasks in the worker output.
[tasks]
...
. myapp.tasks.diffusion.post_activity
...
然后我使用以下命令执行鲜花服务器:
I then execute the flower server with the following command:
$ celery -A myapp.tasks flower
现在,每当我尝试通过Flower REST API发布新任务时,都会出现404错误,并显示错误消息未知任务TASK_NAME".
Now, whenever I try to post a new task via the Flower REST API, I get a 404 error with an error message "Unknown task TASK_NAME".
[W 140423 12:16:17 web:1302] 404 POST /api/task/async-apply/myapp.tasks.diffusion.post_activity (82.225.61.194): Unknown task 'myapp.tasks.diffusion.post_activity'
[W 140423 12:16:17 web:1728] 404 POST /api/task/async-apply/myapp.tasks.diffusion.post_activity (82.225.61.194) 4.68ms
我在花API处理程序中放置了一个pdb断点,看来处理请求时唯一可用的任务如下:
I've put a pdb breakpoint in the flower API handler, and it appears that the only tasks available when the requests is handled are the following:
ipdb> pp celery.tasks
{'celery.backend_cleanup': <@task: celery.backend_cleanup of yoda.tasks.celery:0x7fb9191eb490>,
'celery.chain': <@task: celery.chain of yoda.tasks.celery:0x7fb9191eb490>,
'celery.chord': <@task: celery.chord of yoda.tasks.celery:0x7fb9191eb490>,
'celery.chord_unlock': <@task: celery.chord_unlock of yoda.tasks.celery:0x7fb9191eb490>,
'celery.chunks': <@task: celery.chunks of yoda.tasks.celery:0x7fb9191eb490>,
'celery.group': <@task: celery.group of yoda.tasks.celery:0x7fb9191eb490>,
'celery.map': <@task: celery.map of yoda.tasks.celery:0x7fb9191eb490>,
'celery.starmap': <@task: celery.starmap of yoda.tasks.celery:0x7fb9191eb490>}
似乎没有可用的任务.但是,当我在shell中使用任务 async_apply()
方法时,该任务由工作程序执行.
No tasks seem to be available. However, when I use the task async_apply()
method in a shell, the task is executed by the worker.
知道我在做什么错吗?谢谢!
Any idea what I'm doing wrong? Thank you!
编辑:当我使用芹菜3.0.19和花朵0.5.0时,它看起来很漂亮.
Edit: when I'm using celery 3.0.19 and flower 0.5.0, it works seemelesly.
推荐答案
此错误是由于Flower中的错误所致,现已解决:
This error was due to a bug in Flower and now has been resolved:
问题: https://github.com/mher/flower/issues/200
解决提交问题: https://github.com/mher/flower/commit/bfba1eec90124c92586c480aebaf98ae63c31276
这篇关于“未知任务"发布新任务时芹菜花中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!