當前位置: 首頁>>代碼示例>>Python>>正文


Python WorkerCommand.get_options方法代碼示例

本文整理匯總了Python中celery.bin.celeryd.WorkerCommand.get_options方法的典型用法代碼示例。如果您正苦於以下問題:Python WorkerCommand.get_options方法的具體用法?Python WorkerCommand.get_options怎麽用?Python WorkerCommand.get_options使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在celery.bin.celeryd.WorkerCommand的用法示例。


在下文中一共展示了WorkerCommand.get_options方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from celery.bin.celeryd import WorkerCommand [as 別名]
# 或者: from celery.bin.celeryd.WorkerCommand import get_options [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))
開發者ID:accek,項目名稱:sioworkers,代碼行數:33,代碼來源:worker.py

示例2: main

# 需要導入模塊: from celery.bin.celeryd import WorkerCommand [as 別名]
# 或者: from celery.bin.celeryd.WorkerCommand import get_options [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))
開發者ID:neeraj9,項目名稱:sioworkers,代碼行數:36,代碼來源:worker.py

示例3: update_parser

# 需要導入模塊: from celery.bin.celeryd import WorkerCommand [as 別名]
# 或者: from celery.bin.celeryd.WorkerCommand import get_options [as 別名]
 def update_parser(self, args):
     from celery.bin.celeryd import WorkerCommand
     w = WorkerCommand()
     w.setup_app_from_commandline(['celeryd'])
     for x in w.get_options():
         self.parser.add_option(x)
開發者ID:serchaos,項目名稱:openspending,代碼行數:8,代碼來源:__init__.py


注:本文中的celery.bin.celeryd.WorkerCommand.get_options方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。