是否可以指定如果 celeryd 未运行,task.delay 或 task.apply_async 应该失败?
我正在使用 djcelery 和 djkombu。我本来会使用 RabbitMQ(因为这是推荐的选项),但 RabbitMQ 在我的 VPS 上使用了太多内存,而且我是一个小气鬼。
我认为如果我的代码尝试安排任务并且 celeryd 没有运行,那么在我的应用程序中抛出异常会很好。这是一种由主管、nagios 等监控 celeryd 的备份计划。
起初我认为立即设置可以做到这一点,但它不适用于我的 Django ORM 配置。
I'm using djcelery and djkombu. I would've used RabbitMQ (as that's the recommended option), but RabbitMQ uses too much memory on my VPS and I'm being a cheapskate.
I'm thinking that it would be nice in my app for an exception to be thrown if my code tries to schedule a task and celeryd isn't running. This is sort of a backup plan for having celeryd monitored by supervisor, nagios, etc.
At first I thought the immediate
setting would do this, but it didn't work with my Django ORM configuration.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题主要在于,使用此命令,您向代理发送简单的消息,基本上代理只是存储消息并等待有人使用它。
这种架构最酷的一点是,如果 celery 工作线程宕机两次,当它再次运行时,就会开始获取代理中的所有旧计划任务。
如果您不希望您的项目出现这种行为,那么 celery 可能是错误的选择。
The problem is mainly that with this commands you are sending simple message to the broker, and basically the broker just store the message and wait for someone that consume it.
The cool thing of this architecture is that if a celery worker goes down for two our when it run again starts to fetch all the olds scheduled tasks that are in the broker.
If you don't want this behavior for your project maybe celery is the wrong choice.