芹菜接收任务,但从不执行

时间:2020-01-29 12:30:58

标签: python rabbitmq celery celery-task

我刚刚安装了Celery。

现在,我正在尝试运行以下包含两个文件的基本示例:

tasks.py

from celery import Celery

app = Celery('tasks', broker='amqp://localhost//')

@app.task
def add(x, y):
    return x + y

runme.py

from tasks import add

add.delay(1,2)

我还安装了RabitMQ(无自定义配置)

我按以下方式运行celery worker服务器:

celery -A tasks worker --loglevel=info

到目前为止,一切似乎都可以理解。芹菜也接受了任务

Celery控制台输出(芹菜队列在运行前已清除):


 -------------- celery@ATVIE6124099 v4.4.0 (cliffs)
--- ***** -----
-- ******* ---- Windows-10-10.0.17763-SP0 2020-01-29 13:12:14
- *** --- * ---
- ** ---------- [config]
- ** ---------- .> app:         tasks:0x2033dea8100
- ** ---------- .> transport:   amqp://guest:**@localhost:5672//
- ** ---------- .> results:     disabled://
- *** --- * --- .> concurrency: 8 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
 -------------- [queues]
                .> celery           exchange=celery(direct) key=celery


[tasks]
  . tasks.add

[2020-01-29 13:12:14,688: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2020-01-29 13:12:14,740: INFO/MainProcess] mingle: searching for neighbors
[2020-01-29 13:12:15,033: INFO/SpawnPoolWorker-5] child process 7380 calling self.run()
[2020-01-29 13:12:15,066: INFO/SpawnPoolWorker-1] child process 12864 calling self.run()
[2020-01-29 13:12:15,091: INFO/SpawnPoolWorker-2] child process 3484 calling self.run()
[2020-01-29 13:12:15,105: INFO/SpawnPoolWorker-7] child process 12692 calling self.run()
[2020-01-29 13:12:15,105: INFO/SpawnPoolWorker-6] child process 14056 calling self.run()
[2020-01-29 13:12:15,105: INFO/SpawnPoolWorker-4] child process 4188 calling self.run()
[2020-01-29 13:12:15,131: INFO/SpawnPoolWorker-3] child process 5524 calling self.run()
[2020-01-29 13:12:15,161: INFO/SpawnPoolWorker-8] child process 13388 calling self.run()
[2020-01-29 13:12:15,947: INFO/MainProcess] mingle: all alone
[2020-01-29 13:12:15,964: INFO/MainProcess] celery@ATVIE6124099 ready.
[2020-01-29 13:12:25,998: INFO/MainProcess] Received task: tasks.add[f6dc4156-cdd0-48a5-ab41-d272e4cf68e8]
[2020-01-29 13:12:26,391: INFO/SpawnPoolWorker-9] child process 1296 calling self.run()
[2020-01-29 13:12:26,394: INFO/SpawnPoolWorker-12] child process 13436 calling self.run()
[2020-01-29 13:12:26,396: INFO/SpawnPoolWorker-13] child process 15020 calling self.run()
[2020-01-29 13:12:26,444: INFO/SpawnPoolWorker-11] child process 13376 calling self.run()
[2020-01-29 13:12:26,462: INFO/SpawnPoolWorker-14] child process 5572 calling self.run()
[2020-01-29 13:12:26,471: INFO/SpawnPoolWorker-10] child process 10880 calling self.run()

问题是:从那一步开始,什么都没有发生。收到的任务永远不会成功,因此永远不会在celery控制台上返回任何内容。

我正在使用Windows10和venv来运行celery示例,因为稍后我想将其与Django一起使用。有任何想法吗?预先感谢!

0 个答案:

没有答案