1

I’m trying to implement Celery and RabbitMQ in my Django project with poor results. So I’m trying to create a simple script that simply prints the result of the sum.

from celery import Celery
from time import sleep

app = Celery('tasck', broker='amqp://**_dev:***@204.***.***.43:5**2/ed_dev')

@app.task
def add(x, y):
    sleep(5)
    z = x + y
    return f"return is {z}"

The result is never printed either in this simple script or inside the Django project

I expect that after receiving the task

[2023-04-30 22:14:51,388: INFO/MainProcess] Task tasck.add[c6711609-4da4-44a8-88f7-d78abdaeb7c6] received

Print the result, but as you can see below, no result is printed.

 -------------- celery@ACQUARIO01 v5.2.7 (dawn-chorus)
--- ***** ----- 
-- ******* ---- Windows-10-10.0.22621-SP0 2023-04-30 22:14:46
- *** --- * --- 
- ** ---------- [config]
- ** ---------- .> app:         tasck:0x118dca895d0
- ** ---------- .> transport:   amqp://**_dev:***@204.***.***.43:5**2:5672/ed_dev
- ** ---------- .> results:     disabled://
- *** --- * --- .> concurrency: 16 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** ----- 
 -------------- [queues]
                .> celery           exchange=celery(direct) key=celery


[tasks]
  . tasck.add

[2023-04-30 22:14:46,866: INFO/MainProcess] Connected to amqp://ed_dev:**@204.216.215.43:5672/ed_dev
[2023-04-30 22:14:46,929: INFO/MainProcess] mingle: searching for neighbors
[2023-04-30 22:14:47,262: INFO/SpawnPoolWorker-3] child process 19892 calling self.run()
[2023-04-30 22:14:47,278: INFO/SpawnPoolWorker-1] child process 25156 calling self.run()
[2023-04-30 22:14:47,281: INFO/SpawnPoolWorker-6] child process 27300 calling self.run()
[2023-04-30 22:14:47,289: INFO/SpawnPoolWorker-4] child process 5412 calling self.run()
[2023-04-30 22:14:47,318: INFO/SpawnPoolWorker-2] child process 26668 calling self.run()
[2023-04-30 22:14:47,330: INFO/SpawnPoolWorker-8] child process 17096 calling self.run()
[2023-04-30 22:14:47,331: INFO/SpawnPoolWorker-5] child process 5392 calling self.run()
[2023-04-30 22:14:47,340: INFO/SpawnPoolWorker-7] child process 2680 calling self.run()
[2023-04-30 22:14:47,364: INFO/SpawnPoolWorker-12] child process 25624 calling self.run()
[2023-04-30 22:14:47,370: INFO/SpawnPoolWorker-9] child process 7892 calling self.run()
[2023-04-30 22:14:47,382: INFO/SpawnPoolWorker-10] child process 18956 calling self.run()
[2023-04-30 22:14:47,397: INFO/SpawnPoolWorker-11] child process 15212 calling self.run()
[2023-04-30 22:14:47,400: INFO/SpawnPoolWorker-15] child process 28856 calling self.run()
[2023-04-30 22:14:47,402: INFO/SpawnPoolWorker-13] child process 14972 calling self.run()
[2023-04-30 22:14:47,421: INFO/SpawnPoolWorker-14] child process 25640 calling self.run()
[2023-04-30 22:14:47,426: INFO/SpawnPoolWorker-16] child process 5148 calling self.run()
[2023-04-30 22:14:47,910: INFO/SpawnPoolWorker-17] child process 8736 calling self.run()
[2023-04-30 22:14:47,923: INFO/SpawnPoolWorker-18] child process 27288 calling self.run()
[2023-04-30 22:14:47,924: INFO/SpawnPoolWorker-19] child process 13752 calling self.run()
[2023-04-30 22:14:48,143: INFO/MainProcess] mingle: all alone
[2023-04-30 22:14:48,224: INFO/SpawnPoolWorker-20] child process 16812 calling self.run()
[2023-04-30 22:14:48,382: INFO/MainProcess] celery@ACQUARIO01 ready.
[2023-04-30 22:14:51,388: INFO/MainProcess] Task tasck.add[c6711609-4da4-44a8-88f7-d78abdaeb7c6] received
[2023-04-30 22:14:52,351: INFO/SpawnPoolWorker-21] child process 17752 calling self.run()
[2023-04-30 22:14:52,356: INFO/SpawnPoolWorker-22] child process 10396 calling self.run()
[2023-04-30 22:14:52,368: INFO/SpawnPoolWorker-23] child process 25396 calling self.run()
[2023-04-30 22:14:52,374: INFO/SpawnPoolWorker-24] child process 7952 calling self.run()
[2023-04-30 22:14:52,377: INFO/SpawnPoolWorker-25] child process 27488 calling self.run()
[2023-04-30 22:14:52,389: INFO/SpawnPoolWorker-28] child process 17312 calling self.run()
[2023-04-30 22:14:52,394: INFO/SpawnPoolWorker-27] child process 14072 calling self.run()
[2023-04-30 22:14:52,396: INFO/SpawnPoolWorker-26] child process 18568 calling self.run()
[2023-04-30 22:14:53,111: INFO/SpawnPoolWorker-30] child process 24804 calling self.run()
[2023-04-30 22:14:53,111: INFO/SpawnPoolWorker-29] child process 25416 calling self.run()
[2023-04-30 22:14:53,120: INFO/SpawnPoolWorker-31] child process 7956 calling self.run()
[2023-04-30 22:14:53,923: INFO/SpawnPoolWorker-32] child process 23032 calling self.run()
[2023-04-30 22:14:53,928: INFO/SpawnPoolWorker-33] child process 11852 calling self.run()
[2023-04-30 22:14:54,717: INFO/SpawnPoolWorker-34] child process 25580 calling self.run()
[2023-04-30 22:14:55,529: INFO/SpawnPoolWorker-35] child process 15468 calling self.run()
[2023-04-30 22:14:56,329: INFO/SpawnPoolWorker-36] child process 8180 calling self.run()
[2023-04-30 22:14:57,141: INFO/SpawnPoolWorker-37] child process 27240 calling self.run()
[2023-04-30 22:14:57,959: INFO/SpawnPoolWorker-38] child process 29432 calling self.run()
[2023-04-30 22:14:58,770: INFO/SpawnPoolWorker-39] child process 21840 calling self.run()

Why do you think

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.