I am using the official celery project for django, but it is not working on my machine.
I have installed all the necessary modules, and am using the example given in the link: Example Django project using Celery.
I have already searched for the same error and used some solutions, but no solution fixed my problem. When I use the command: celery -A proj worker -l INFO, I get this response:
--- ***** -----
-- ******* ---- 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?
CodePudding user response:
Celery doesn't support Windows.
But you can use eventlet to run it on Win, as described here
Also, make sure, that you have installed RabbitMQ locally and it's running in port 5672. Also, you need to specify credentials for amqp server in settings.py
From your guide
The settings file assumes that rabbitmq-server is running on localhost using the default ports.
Also, you can run amqp server as docker container. It could be easier option than installing it locally:
docker run -d -p 5672:5672 -p 15672:15672 rabbitmq:3-management