我已经在一个模块中定义了一个Celery应用程序,现在我想从__main__中的同一个模块启动工作,即通过从命令行运行
Python -m而不是芹菜来运行模块.我试过这个:
app = Celery('project', include=['project.tasks'])
# do all kind of project-specific configuration
# that should occur whenever this module is imported
if __name__ == '__main__':
# log stuff about the configuration
app.start(['worker', '-A', 'project.tasks'])
但是现在芹菜认为我正在运行这个工人,没有争议:
Usage: worker [options]
Show help screen and exit.
Options:
-A APP, --app=APP app instance to use (e.g. module.attr_name)
[snip]
使用消息是从芹菜 – 帮助中获得的消息,就像没有得到命令一样.我也试过
app.worker_main(['-A', 'project.tasks'])
但是抱怨-A不被认可.
那么我该怎么做呢?或者,如何将回调传递给工作人员以使其记录有关其配置的信息?