芹菜任务未执行 - 芹菜不工作的最简单示例

发布于 2025-01-18 10:01:42 字数 1125 浏览 4 评论 0原文

我在运行非常基本的、实际上是最简单的 celery 示例时遇到了麻烦。

你能指导我是否我在这里做错了什么?

工作部分:

from celery import Celery

celery = Celery('tasks', broker='redis://localhost:6379/0',backend='redis://localhost:6379/1')

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

并运行它: celery -Atasksworker --loglevel=INFO

然后我打开新终端并输入:

>>> from tasks import add
>>> result = add.delay(1,1)
>>> 

result.ready() 始终为 False

并在芹菜工人我看不到已完成的任务,仅收到并运行。

[2022-04-01 13:07:23,434: INFO/MainProcess] Task tasks.add[b0b98051-53b3-4fec-8f83-b1f74be27cfa] received
[2022-04-01 13:07:24,304: INFO/SpawnPoolWorker-19] child process 31632 calling self.run()
[2022-04-01 13:07:24,318: INFO/SpawnPoolWorker-20] child process 4648 calling self.run()
[2022-04-01 13:07:24,322: INFO/SpawnPoolWorker-21] child process 3984 calling self.run()

输入图片此处描述

我做错了什么? 谢谢!

I have troubles running very basic, actually the simplest celery example.

Can You guide me whether I'm doing something wrong here?

worker part:

from celery import Celery

celery = Celery('tasks', broker='redis://localhost:6379/0',backend='redis://localhost:6379/1')

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

and run it with:
celery -A tasks worker --loglevel=INFO

then I open new terminal and type:

>>> from tasks import add
>>> result = add.delay(1,1)
>>> 

but result.ready() is always False

and in the celery worker I cannot see task that is finished only received and run.

[2022-04-01 13:07:23,434: INFO/MainProcess] Task tasks.add[b0b98051-53b3-4fec-8f83-b1f74be27cfa] received
[2022-04-01 13:07:24,304: INFO/SpawnPoolWorker-19] child process 31632 calling self.run()
[2022-04-01 13:07:24,318: INFO/SpawnPoolWorker-20] child process 4648 calling self.run()
[2022-04-01 13:07:24,322: INFO/SpawnPoolWorker-21] child process 3984 calling self.run()

enter image description here

What am I doing wrong?
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光与爱终年不遇 2025-01-25 10:01:42

您正在尝试在不支持的窗口上运行芹菜。 https:///docseceleryq.dev/en/en/最新/faq.html#do-celery-support-windows

芹菜支持窗户?答案:否。

由于芹菜4.x,由于缺乏,不再支持窗户
资源。

,但它可能仍然有效,我们很乐意接受补丁。

You are attempting to run Celery on Windows which is unsupported. https://docs.celeryq.dev/en/latest/faq.html#does-celery-support-windows

Does Celery support Windows? Answer: No.

Since Celery 4.x, Windows is no longer supported due to lack of
resources.

But it may still work and we are happy to accept patches.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文