我已经在一个模块中定义了一个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 <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
没有被识别。
我该怎么做?或者,我如何将回调传递给worker,让它记录有关其配置的信息?
我想你只是没有把args包装起来,这样芹菜就能读出来,比如:
使用app.worker_main方法(v3.1.12):
基于code from Django-Celery module您可以尝试以下方法:
相关问题 更多 >
编程相关推荐