我尝试用RabbitMQ(3.8.19)(Django 4.1.5)设置Celery(5.2.7),结果,任务出现在“celery”队列中,状态为“Unacked”,30分钟后,它进入“Ready”状态,并显示一条消息。“amqp.exceptions.PreconditionFailed:(0,0):(406)PRECONDITION_FAILED -通道1上的传递确认超时。使用的超时值:1800000毫秒。此超时值可以配置,请参阅消费者文档指南了解更多信息”
当直接调用该方法时(不带.delay),一切都正常工作。
我不知道哪些配置不正确
celery :$celery -我的本地工人-l信息
-------------- celery@DEV2 v5.2.7 (dawn-chorus)
--- ***** -----
-- ******* ---- Windows-1
- *** --- * ---
- ** ---------- [config]
- ** ---------- .> app: mylocal:0x18205ade830
- ** ---------- .> transport: amqp://<RMQLogin>:**@<RMQ_HOST>:<RMQ_PORT>/<RMQ_VIRTUAL_HOST>
- ** ---------- .> results: disabled://
- *** --- * --- .> concurrency: 12 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery
[tasks]
. myapp.tasks.send_spam_email
项目结构:
x一个一个一个一个x一个一个二个x
2023-03-09
尝试以相同效果使用配置:已添加到settings.py:
CELERY_RESULT_BACKEND = 'rpc://'
$ celery -A mylocal worker -l info -E
-------------- celery@DEV2 v5.2.7 (dawn-chorus)
--- ***** -----
-- ******* ---- Windows-1
- *** --- * ---
- ** ---------- [config]
- ** ---------- .> app: mylocal:0x1e64be5e800
- ** ---------- .> transport: amqp://<RMQLogin>:**@<RMQ_HOST>:<RMQ_PORT>/<RMQ_VIRTUAL_HOST>
- ** ---------- .> results: rpc://
- *** --- * --- .> concurrency: 12 (prefork)
-- ******* ---- .> task events: ON
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery
....
[2023-03-09 12:09:43,316: INFO/MainProcess] Task myapp.tasks.send_spam_email[5cebb2d5-5d19-44e5-b638-f4f86b201df4] received
[2023-03-09 12:09:43,317: INFO/MainProcess] Task myapp.tasks.send_spam_email[f8d7243b-d75e-46c8-b733-4ec080500e60] received
[2023-03-09 12:09:43,318: INFO/MainProcess] Task myapp.tasks.send_spam_email[03ce1b24-4d97-41c5-8765-cd71850d452f] received
1条答案
按热度按时间hlswsv351#
添加**--pool=solo解决问题
$celery -我的本地工人-l信息-E--池=独奏**