【发布时间】:2012-11-16 20:43:33
【问题描述】:
我有一个带有 sqlalchemy 的烧瓶应用程序和一个 celery worker 正在运行。我使用 redis 作为我的经纪人。每次有人在对话中提交新消息时,都会启动一个工作人员,并且应该向所有参与对话的人发送通知邮件。因此它连接到数据库并获取所有相关的电子邮件地址。
不幸的是,似乎有一个随机因素决定了 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
我还不能确定一个系统,什么时候可以工作,什么时候不工作。但我已将所有相关软件包升级到今天可用的最新版本,但仍然无法使用。
我希望对为什么这可能不起作用以及如何解决它有任何想法。非常感谢每一个反馈,因为我有点绝望!
【问题讨论】:
标签: redis celery celery-task