redis - 如果 celery (显然)随机忘记任务,我该怎么办?

标签 redis celery celery-task

我有一个带有 sqlalchemy 的 flask 应用程序和一个正在运行的 celery worker。我使用 redis 作为我的经纪人。每次有人在对话中提交新消息时,都会启动一个 worker 并向所有参与对话的人发送通知邮件。因此它连接到数据库并获取所有相关的电子邮件地址。

不幸的是,似乎有一个随机因素决定,celery 是否知道发送邮件的任务。在一些启动后它完美地工作(有时),在一些启动后它根本不工作。当它不起作用时,我得到的错误是:

[2012-11-28 21:42:58,751: ERROR/MainProcess] Received unregistered task of type 'messages.sendnotifies'.
 The message has been ignored and discarded.

 Did you remember to import the module containing this task?
 Or maybe you are using relative imports?
 Please see http://bit.ly/gLye1c for more information.

 The full contents of the message body was:
 {'retries': 0, 'task': 'messages.sendnotifies', 'eta': None, 'args': [41L], 'expires': None, 'callbacks': None, 'errbacks': None, 'kwargs': {}, 'id': '47da3ba7-ec91-4056-bb4f-a6afec2f960f', 'utc': True} (183b)
 Traceback (most recent call last):
   File "/var/www/virtual/venv/lib/python2.7/site-packages/celery/worker/consumer.py", line 410, in on_task_received
     connection = self.connection
 KeyError: 'messages.sendnotifies'

当我使用 --loglevel=DEBUG 运行 celery 时,它会在任务列表中列出任务:

[Tasks]
   . celery.backend_cleanup
   . celery.chain
   . celery.chord
   . celery.chord_unlock
   . celery.chunks
   . celery.group
   . celery.map
   . celery.starmap
   . event.notfiy
   . messages.sendnotifies
   . money.checktransaction
   . money.deploypayment
   . money.invoicepromotion
   . protocols.plotweight
   . questionnaire.deploy
   . questionnaire.suitability
   . registration.notify
   . tracking.track
   . user.checkaccount
   . user.checkaccounts
   . user.fixpermissions
   . user.genpassreset

我还不能确定一个系统,什么时候工作,什么时候不工作。但是我已经将所有相关软件包升级到今天可用的最新版本,但仍然无法正常工作。

我希望就为什么这可能不起作用以及我如何修复它提出任何想法。非常感谢每一个反馈,因为我有点绝望!

最佳答案

这可能是目前3.0开发中修复的bug,你可以帮忙测试一下 安装:

pip 安装 https://github.com/celery/celery/zipball/3.0

关于redis - 如果 celery (显然)随机忘记任务,我该怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13614550/

相关文章:

python - 调整 celery 以获得高性能

python - Celery Flower - 我如何加载以前捕获的任务?

ruby-on-rails - 我正在尝试将我的 ruby​​ on rails 应用程序部署到 heroku 并且它部署正确

python - AsyncResult(task_id) 即使在任务开始后也返回 "PENDING"状态

python - django celery 和弦任务错误

python - 如何在 Celery 中创建共享计数器?

Python Celery 任务在没有后端的情况下完成

redis - 如何使用 Redis 防止竞争条件?

c# - 未经许可注册servicestack?

redis - redis中的容器数据类型是什么?