芹菜有效,但花不起作用
Celery works, but with flower doesn't work
我已经安装了 celery 和 RabitMQ 以及 flower。我可以浏览到花港。我有以下简单的工作人员,我可以附加到 celery 并从 python 程序调用:
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 12 16:37:33 2015
@author: idf
"""
from celery import Celery
app = Celery('tasks', broker='amqp://guest@localhost//')
@app.task
def add(x, y):
return x + y
本程序调用它
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 12 16:40:16 2015
@author: idf
"""
from tasks import add
add.delay(36, 5)
我是这样开始芹菜的:
idf@DellInsp:~/Documents/Projects/python3$ celery -A tasks worker --loglevel=info
[2015-12-12 19:22:46,223: WARNING/MainProcess] /home/idf/anaconda3/lib/python3.5/site-packages/celery/apps/worker.py:161: CDeprecationWarning:
Starting from version 3.2 Celery will refuse to accept pickle by default.
The pickle serializer is a security concern as it may give attackers
the ability to execute any command. It's important to secure
your broker from unauthorized access when using pickle, so we think
that enabling pickle should require a deliberate action and not be
the default choice.
If you depend on pickle then you should set a setting to disable this
warning and to be sure that everything will continue working
when you upgrade to Celery 3.2::
CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
You must only enable the serializers that you will actually use.
warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))
-------------- celery@DellInsp v3.1.19 (Cipater)
---- **** -----
--- * *** * -- Linux-3.19.0-39-lowlatency-x86_64-with-debian-jessie-sid
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: tasks:0x7f61485e61d0
- ** ---------- .> transport: amqp://guest:**@localhost:5672//
- ** ---------- .> results: disabled
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ----
--- ***** ----- [queues]
-------------- .> celery exchange=celery(direct) key=celery
[tasks]
. tasks.add
[2015-12-12 19:22:46,250: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2015-12-12 19:22:46,267: INFO/MainProcess] mingle: searching for neighbors
[2015-12-12 19:22:47,275: INFO/MainProcess] mingle: all alone
[2015-12-12 19:22:47,286: WARNING/MainProcess] celery@DellInsp ready.
[2015-12-12 19:22:47,288: INFO/MainProcess] Received task: tasks.add[3c0e5317-ac53-465e-a8fd-3e2861e31db6]
[2015-12-12 19:22:47,289: INFO/MainProcess] Task tasks.add[3c0e5317-ac53-465e-a8fd-3e2861e31db6] succeeded in 0.00045899399992777035s: 41
^C
worker: Hitting Ctrl+C again will terminate all running tasks!
worker: Warm shutdown (MainProcess)
注意41
的正确输出
但是,如果我传入 flower
参数,当我执行调用时没有任何反应。我在 flower
网站上也没有看到任何任务。
idf@DellInsp:~/Documents/Projects/python3$ celery flower -A tasks worker --loglevel=info
[I 151212 19:23:59 command:113] Visit me at http://localhost:5555
[I 151212 19:23:59 command:115] Broker: amqp://guest:**@localhost:5672//
[I 151212 19:23:59 command:118] Registered tasks:
['celery.backend_cleanup',
'celery.chain',
'celery.chord',
'celery.chord_unlock',
'celery.chunks',
'celery.group',
'celery.map',
'celery.starmap',
'tasks.add']
[I 151212 19:23:59 mixins:231] Connected to amqp://guest:**@127.0.0.1:5672//
[W 151212 19:24:01 control:44] 'stats' inspect method failed
[W 151212 19:24:01 control:44] 'active_queues' inspect method failed
[W 151212 19:24:01 control:44] 'registered' inspect method failed
[W 151212 19:24:01 control:44] 'scheduled' inspect method failed
[W 151212 19:24:01 control:44] 'active' inspect method failed
[W 151212 19:24:01 control:44] 'reserved' inspect method failed
[W 151212 19:24:01 control:44] 'revoked' inspect method failed
[W 151212 19:24:01 control:44] 'conf' inspect method failed
^Cidf@DellInsp:~/Documents/Projects/python3$
最后,不确定是不是错误,我的花卉网站没有工人标签
我不确定我是否理解,但是你运行把花和工人放在一起吗? Flower 不处理任务。两者都必须 运行,然后 Flower 可以用作监控工具。
运行芹菜:
celery -A tasks worker --loglevel=info
再开一朵shell和运行花:
celery -A tasks flower --loglevel=info
然后去 http://localhost:5555 看看你的工人。当然,如果你想看到一些东西,你必须 运行 一些任务。
我已经安装了 celery 和 RabitMQ 以及 flower。我可以浏览到花港。我有以下简单的工作人员,我可以附加到 celery 并从 python 程序调用:
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 12 16:37:33 2015
@author: idf
"""
from celery import Celery
app = Celery('tasks', broker='amqp://guest@localhost//')
@app.task
def add(x, y):
return x + y
本程序调用它
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 12 16:40:16 2015
@author: idf
"""
from tasks import add
add.delay(36, 5)
我是这样开始芹菜的:
idf@DellInsp:~/Documents/Projects/python3$ celery -A tasks worker --loglevel=info
[2015-12-12 19:22:46,223: WARNING/MainProcess] /home/idf/anaconda3/lib/python3.5/site-packages/celery/apps/worker.py:161: CDeprecationWarning:
Starting from version 3.2 Celery will refuse to accept pickle by default.
The pickle serializer is a security concern as it may give attackers
the ability to execute any command. It's important to secure
your broker from unauthorized access when using pickle, so we think
that enabling pickle should require a deliberate action and not be
the default choice.
If you depend on pickle then you should set a setting to disable this
warning and to be sure that everything will continue working
when you upgrade to Celery 3.2::
CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
You must only enable the serializers that you will actually use.
warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))
-------------- celery@DellInsp v3.1.19 (Cipater)
---- **** -----
--- * *** * -- Linux-3.19.0-39-lowlatency-x86_64-with-debian-jessie-sid
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: tasks:0x7f61485e61d0
- ** ---------- .> transport: amqp://guest:**@localhost:5672//
- ** ---------- .> results: disabled
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ----
--- ***** ----- [queues]
-------------- .> celery exchange=celery(direct) key=celery
[tasks]
. tasks.add
[2015-12-12 19:22:46,250: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2015-12-12 19:22:46,267: INFO/MainProcess] mingle: searching for neighbors
[2015-12-12 19:22:47,275: INFO/MainProcess] mingle: all alone
[2015-12-12 19:22:47,286: WARNING/MainProcess] celery@DellInsp ready.
[2015-12-12 19:22:47,288: INFO/MainProcess] Received task: tasks.add[3c0e5317-ac53-465e-a8fd-3e2861e31db6]
[2015-12-12 19:22:47,289: INFO/MainProcess] Task tasks.add[3c0e5317-ac53-465e-a8fd-3e2861e31db6] succeeded in 0.00045899399992777035s: 41
^C
worker: Hitting Ctrl+C again will terminate all running tasks!
worker: Warm shutdown (MainProcess)
注意41
但是,如果我传入 flower
参数,当我执行调用时没有任何反应。我在 flower
网站上也没有看到任何任务。
idf@DellInsp:~/Documents/Projects/python3$ celery flower -A tasks worker --loglevel=info
[I 151212 19:23:59 command:113] Visit me at http://localhost:5555
[I 151212 19:23:59 command:115] Broker: amqp://guest:**@localhost:5672//
[I 151212 19:23:59 command:118] Registered tasks:
['celery.backend_cleanup',
'celery.chain',
'celery.chord',
'celery.chord_unlock',
'celery.chunks',
'celery.group',
'celery.map',
'celery.starmap',
'tasks.add']
[I 151212 19:23:59 mixins:231] Connected to amqp://guest:**@127.0.0.1:5672//
[W 151212 19:24:01 control:44] 'stats' inspect method failed
[W 151212 19:24:01 control:44] 'active_queues' inspect method failed
[W 151212 19:24:01 control:44] 'registered' inspect method failed
[W 151212 19:24:01 control:44] 'scheduled' inspect method failed
[W 151212 19:24:01 control:44] 'active' inspect method failed
[W 151212 19:24:01 control:44] 'reserved' inspect method failed
[W 151212 19:24:01 control:44] 'revoked' inspect method failed
[W 151212 19:24:01 control:44] 'conf' inspect method failed
^Cidf@DellInsp:~/Documents/Projects/python3$
最后,不确定是不是错误,我的花卉网站没有工人标签
我不确定我是否理解,但是你运行把花和工人放在一起吗? Flower 不处理任务。两者都必须 运行,然后 Flower 可以用作监控工具。
运行芹菜:
celery -A tasks worker --loglevel=info
再开一朵shell和运行花:
celery -A tasks flower --loglevel=info
然后去 http://localhost:5555 看看你的工人。当然,如果你想看到一些东西,你必须 运行 一些任务。