我已经Celery
在一个模块中定义了一个应用程序,现在我想从它的同一个模块启动工作程序__main__
,即通过运行模块python -m
而不是celery
从命令行。我试过这个:
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'])
但现在 Celery 认为我正在运行没有参数的工人:
Usage: worker <command> [options]
Show help screen and exit.
Options:
-A APP, --app=APP app instance to use (e.g. module.attr_name)
[snip]
使用消息是您从中获得的消息celery --help
,就好像它没有收到命令一样。我也试过
app.worker_main(['-A', 'project.tasks'])
但这抱怨-A
不被认可。
那么我该怎么做呢?或者,我如何将回调传递给工作人员以使其记录有关其配置的信息?