【发布时间】:2022-06-29 19:21:55
【问题描述】:
我有一个芹菜工人作为经纪人运行 redis。 启动工作进程给了我这个:
celery -A celeryworker worker --loglevel=INFO
-------------- celery@cd38f5e26c28 v5.2.1 (dawn-chorus)
--- ***** -----
-- ******* ---- Linux-5.10.25-linuxkit-x86_64-with-glibc2.28 2021-12-14 00:22:02
- *** --- * ---
- ** ---------- [config]
- ** ---------- .> app: myapp:0x7f96dd51af10
- ** ---------- .> transport: redis://redis-container:6379/1
- ** ---------- .> results: disabled://
- *** --- * --- .> concurrency: 6 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> 0 exchange=0(direct) key=0
[tasks]
. app.tasks.bye
. app.tasks.printme
[2021-12-14 00:22:02,708: INFO/MainProcess] Connected to redis://redis-container:6379/1
[2021-12-14 00:22:02,717: INFO/MainProcess] mingle: searching for neighbors
[2021-12-14 00:22:03,740: INFO/MainProcess] mingle: all alone
[2021-12-14 00:22:03,762: INFO/MainProcess] celery@cd38f5e26c28 ready.
[2021-12-14 00:22:23,332: INFO/MainProcess] Task app.task.bye[7e28e6a0-8aaa-4609-bd85-9312e91cb355] received
[2021-12-14 00:23:23,326: INFO/ForkPoolWorker-3] Task app.tasks.bye[7e28e6a0-8aaa-4609-bd85-9312e91cb355] succeeded in 60.061842500006605s: 'the text was byebye!!'
这是我在启动 celery workers 后在 redis 中看到的内容:
127.0.0.1:6379[1]> keys *
1) "_kombu.binding.0"
2) "_kombu.binding.celery.pidbox"
3) "_kombu.binding.celeryev"
即使我在我的任务 (sleep(60)) 上设置了一个长计时器,任务也需要 60 秒才能运行,但我仍然在我的 redis 容器中看不到任何内容。
mget <key> 为以上所有键返回 nil。
我希望看到以 ID 或其他形式传入 Redis 的消息(如果我使用 SQS 作为代理,我可以看到消息,但对于 redis 则不行)。
【问题讨论】:
-
我相信这些信息转瞬即逝。一旦工人接手工作,我相信这些信息就会消失。然后,如果您选择将结果存储在这种后端中,那么将结果存储在 Redis 中需要很长时间。这是一个很好的问题 IMO,但我还没有找到答案。