我按照官方教程/ doc的说法为我的Django项目安装了Celery。 当我在命令行启动芹菜时,它可以正常工作,我可以看到它接收任务并执行它们。 但是,一旦一切正常,我决定跟随文件多一点,以保护芹菜,让它一直运行。 所以我尝试在Ubuntu系统上使用/ etc / default / celeryd脚本提供celeryd init脚本。 我相应地改变了这个值,并且它正确的启动,但是当它接收到一个任务时,日志会说:
ERROR/MainProcess] Received unregistered task of type 'likes.tasks.test'. 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.
然后我得到了任务所要求的细节。 再一次,当我在命令行上启动芹菜而没有任何configuration时,这个任务完美地工作。 在这一点上会出现什么问题? 我使用虚拟环境,以防万一它会改变任何东西,但我也在configuration文件中指定它。
迟到的答案,但也许它有助于某人。
你见过http://docs.celeryproject.org/en/latest/userguide/tasks.html#automatic-naming-and-relative-imports ?
你应该使用--loglevel=info来启动worker,这样它就会在启动时logging一个注册任务的列表。 您必须确保任务注册的名称与您在邮件中发送的名称相匹配。