芹菜和RabbitMQ无法启动

时间:2019-01-18 02:01:10

标签: python rabbitmq

我安装了RabbitMQ,Celery,Flask和Python,但是当我尝试运行celery worker进行测试时。它不起作用,这些是在cmd中弹出的错误。

[2019-01-18 09:56:37,443: WARNING/MainProcess] consumer: Connection to broker lost. Trying to re-establish the connection...
Traceback (most recent call last):
  File "c:\users\ansonkho\anaconda3\lib\site-packages\celery\worker\consumer\consumer.py", line 317, in start
    blueprint.start(self)
  File "c:\users\ansonkho\anaconda3\lib\site-packages\celery\bootsteps.py", line 119, in start
    step.start(parent)
  File "c:\users\ansonkho\anaconda3\lib\site-packages\celery\worker\consumer\mingle.py", line 40, in start
    self.sync(c)
  File "c:\users\ansonkho\anaconda3\lib\site-packages\celery\worker\consumer\mingle.py", line 44, in sync
    replies = self.send_hello(c)
  File "c:\users\ansonkho\anaconda3\lib\site-packages\celery\worker\consumer\mingle.py", line 57, in send_hello
    replies = inspect.hello(c.hostname, our_revoked._data) or {}

下面是我的代码:

from celery import Celery

app = Celery('test_celery', broker='amqp://myuser:mypassword@localhost/myvhost',backend='rpc://')

1 个答案:

答案 0 :(得分:2)

[2019-01-18 09:56:37,443: WARNING/MainProcess] consumer: Connection to broker lost. Trying to re-establish the connection...

如错误所述,没有代理运行。建立连接之前,您需要启动Rabbitmq。这就是为什么由于代理未运行而导致消费者抛出Connection to broker lost的原因。