本文整理汇总了Python中celery.bin.celeryd.WorkerCommand.run方法的典型用法代码示例。如果您正苦于以下问题:Python WorkerCommand.run方法的具体用法?Python WorkerCommand.run怎么用?Python WorkerCommand.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.bin.celeryd.WorkerCommand
的用法示例。
在下文中一共展示了WorkerCommand.run方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from celery.bin.celeryd import WorkerCommand [as 别名]
# 或者: from celery.bin.celeryd.WorkerCommand import run [as 别名]
def main(argv=sys.argv): # pragma: no cover
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
env = bootstrap(config_uri)
worker = WorkerCommand(app=Celery(env))
worker.run()
示例2: main
# 需要导入模块: from celery.bin.celeryd import WorkerCommand [as 别名]
# 或者: from celery.bin.celeryd.WorkerCommand import run [as 别名]
def main():
usage = "usage: %prog [options] [broker-url]"
epilog = """\
The worker needs Filetracker server configured. If no FILETRACKER_URL is
present in the environment, a sensible default is generated, using the same
host as the Celery broker uses, with default Filetracker port."""
parser = OptionParser(usage=usage, epilog=epilog)
parser.disable_interspersed_args()
os.environ.setdefault('CELERY_CONFIG_MODULE', 'sio.celery.default_config')
app = Celery()
cmd = WorkerCommand(app)
for x in cmd.get_options():
parser.add_option(x)
options, args = parser.parse_args()
if len(args) > 1:
parser.error("Unexpected arguments: " + ' '.join(args[1:]))
if args:
broker_url = args[0]
os.environ['CELERY_BROKER_URL'] = args[0]
if 'FILETRACKER_URL' not in os.environ:
default_filetracker_host = None
if 'CELERY_BROKER_URL' in os.environ:
default_filetracker_host = \
_host_from_url(os.environ['CELERY_BROKER_URL'])
if not default_filetracker_host:
default_filetracker_host = '127.0.0.1'
os.environ['FILETRACKER_URL'] = 'http://%s:%d' \
% (default_filetracker_host, DEFAULT_FILETRACKER_PORT)
return cmd.run(**vars(options))
示例3: main
# 需要导入模块: from celery.bin.celeryd import WorkerCommand [as 别名]
# 或者: from celery.bin.celeryd.WorkerCommand import run [as 别名]
def main():
usage = "usage: %prog [options] [broker-url]"
epilog = """\
The worker needs Filetracker server configured. If no FILETRACKER_URL is
present in the environment, a sensible default is generated, using the same
host as the Celery broker uses, with default Filetracker port."""
parser = OptionParser(usage=usage, epilog=epilog)
parser.disable_interspersed_args()
app = Celery(loader=Loader)
cmd = WorkerCommand(app)
for x in cmd.get_options():
parser.add_option(x)
options, args = parser.parse_args()
if len(args) > 1:
parser.error("Unexpected arguments: " + " ".join(args[1:]))
if args:
broker_url = args[0]
os.environ["CELERY_BROKER_URL"] = args[0]
if "FILETRACKER_URL" not in os.environ:
default_filetracker_host = None
if "CELERY_BROKER_URL" in os.environ:
default_filetracker_host = _host_from_url(os.environ["CELERY_BROKER_URL"])
if not default_filetracker_host:
default_filetracker_host = "127.0.0.1"
os.environ["FILETRACKER_URL"] = "http://%s:%d" % (default_filetracker_host, DEFAULT_FILETRACKER_PORT)
return cmd.run(**vars(options))
示例4: test_setup_concurrency_very_early
# 需要导入模块: from celery.bin.celeryd import WorkerCommand [as 别名]
# 或者: from celery.bin.celeryd.WorkerCommand import run [as 别名]
def test_setup_concurrency_very_early(self):
x = WorkerCommand()
x.run = Mock()
with self.assertRaises(ImportError):
x.execute_from_commandline(['celeryd', '-P', 'xyzybox'])
示例5: test_invalid_loglevel_gives_error
# 需要导入模块: from celery.bin.celeryd import WorkerCommand [as 别名]
# 或者: from celery.bin.celeryd.WorkerCommand import run [as 别名]
def test_invalid_loglevel_gives_error(self):
x = WorkerCommand(app=Celery(set_as_current=False))
with self.assertRaises(SystemExit):
x.run(loglevel='GRIM_REAPER')