Django 的官方芹菜项目无法正常工作

Official celery project for django is not working

我正在使用 django 的官方 celery 项目,但它无法在我的机器上运行。

我已经安装了所有必要的模块,并且正在使用 link 中给出的示例:Example Django project using Celery

我已经搜索过相同的错误并使用了一些解决方案,但没有任何解决方案可以解决我的问题。当我使用命令时:celery -A proj worker -l INFO,我得到这样的响应:

--- ***** -----
-- ******* ---- Windows-10-10.0.22000-SP0 2022-05-16 14:19:39
- *** --- * ---
- ** ---------- [config]
- ** ---------- .> app:         proj:0x230fa67a6a0
- ** ---------- .> transport:   amqp://guest:**@localhost:5672//
- ** ---------- .> results:
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
 -------------- [queues]
                .> celery           exchange=celery(direct) key=celery


[tasks]
  . demoapp.tasks.add
  . demoapp.tasks.count_widgets
  . demoapp.tasks.mul
  . demoapp.tasks.rename_widget
  . demoapp.tasks.xsum
  . proj.celery.debug_task

[2022-05-16 14:19:40,464: INFO/SpawnPoolWorker-4] child process 7240 calling self.run()
[2022-05-16 14:19:40,481: INFO/SpawnPoolWorker-3] child process 6960 calling self.run()
[2022-05-16 14:19:40,493: INFO/SpawnPoolWorker-2] child process 10964 calling self.run()
[2022-05-16 14:19:40,516: INFO/SpawnPoolWorker-1] child process 6272 calling self.run()
[2022-05-16 14:19:41,978: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [WinError 10061]```

As I said I am using the source code itself, can anyone tell me how I can solve this problem?

芹菜doesn't support Windows.

但是你可以在 Win 上使用 eventlet 运行 它,如所述

此外,请确保您已在本地安装 RabbitMQ 并且它在端口 5672 中 运行ning。此外,您需要在 settings.py[= 中指定 amqp 服务器的凭据16=]

来自您的指南

The settings file assumes that rabbitmq-server is running on localhost using the default ports.

此外,您可以 运行 amqp 服务器作为 docker 容器。它可能比在本地安装更简单:

docker run -d -p 5672:5672 -p 15672:15672 rabbitmq:3-management