我让一个celery 工人做Redis的经纪人启动worker进程可以得到以下结果:
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 工人后在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则不行)。
1条答案
按热度按时间mkshixfv1#
您的邮件将立即由您的工作人员拾取。要查看Redis将它们存储在何处,请执行以下操作:
1.停止你的worker进程-这样消息就不会从redis弹出
1.打开python shell并执行任务-
task.delay(*args, **kwargs)
你会在你的Redis中的
celery
键下找到你的消息:检查您的celery broker URL并查看它使用的是哪个logical database