Django与芹菜:计划任务(ETA)并行执行多次

时间:2022-01-03 02:17:34

I'm developing a web application with Django which uses Celery to process asynchronous tasks, especially for transactional emails.

我正在用Django开发一个web应用程序,该应用程序使用芹菜处理异步任务,特别是针对事务性电子邮件。

One on my email task is scheduled with the ETA option but it's executed multiple times in parallel resulting in mail chain, very anoying. I can't figure out exactly why. I checked twice my Django code and I'm sure that it is publish only one time.

我的电子邮件任务中有一个是用ETA选项安排的,但是它被并行地执行了多次,导致了邮件链,非常麻烦。我不知道确切的原因。我检查了两次Django代码,我确信它只发布了一次。

I'm using Redis as a broker/backend result.

我使用Redis作为代理/后端结果。

My Celery daemon is hosted on Heroku and launched via this command:

我的芹菜守护进程托管在Heroku上,通过以下命令启动:

python manage.py celeryd -E -B --loglevel=INFO

Thanks for your help.

谢谢你的帮助。

EDIT: I find a valid solution here thanks to a guy on the #celery IRC channel: http://loose-bits.com/2010/10/distributed-task-locking-in-celery.html

编辑:我在这里找到了一个有效的解决方案,感谢一个在#芹菜IRC频道的家伙:http://loose-bits.com/2010/10/distributed-task-locking- celery.html

1 个解决方案

#1


2  

Have you checked the Ensuring a task is only executed one at a time docs?

您是否检查过确保一个任务一次只执行一个文档?

#1


2  

Have you checked the Ensuring a task is only executed one at a time docs?

您是否检查过确保一个任务一次只执行一个文档?