当前位置: 首页>>代码示例>>Python>>正文


Python Watcher.get方法代码示例

本文整理汇总了Python中circus.watcher.Watcher.get方法的典型用法代码示例。如果您正苦于以下问题:Python Watcher.get方法的具体用法?Python Watcher.get怎么用?Python Watcher.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在circus.watcher.Watcher的用法示例。


在下文中一共展示了Watcher.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_arbiter

# 需要导入模块: from circus.watcher import Watcher [as 别名]
# 或者: from circus.watcher.Watcher import get [as 别名]
def get_arbiter(watchers, controller='tcp://127.0.0.1:5555',
                pubsub_endpoint='tcp://127.0.0.1:5556',
                env=None, name=None, context=None,
                check_flapping=True, background=False):
    """Creates a Arbiter and a single watcher in it.

    Options:

    - **watchers** -- a list of watchers. A watcher in that case is a
      dict containing:

        - **name** -- the name of the watcher (default: None)
        - **cmd** -- the command line used to run the Watcher.
        - **numprocesses** -- the number of flies to spawn (default: 1).
        - **warmup_delay** -- the delay in seconds between two spawns
          (default: 0)
        - **shell** -- if True, the flies are run in the shell
          (default: False)
        - **working_dir** - the working dir for the processes (default: None)
        - **uid** -- the user id used to run the flies (default: None)
        - **gid** -- the group id used to run the flies (default: None)
        - **env** -- the environment passed to the flies (default: None)

    - **controller** -- the zmq entry point (default: 'tcp://127.0.0.1:5555')
    - **pubsub_endpoint** -- the zmq entry point for the pubsub
      (default: 'tcp://127.0.0.1:5556')
    - **context** -- the zmq context (default: None)
    - **check_flapping** -- If True, the flapping detection is activated.
      (default:True)
    - **background** -- If True, the arbiter is launched in a thread in the
      background (default: False)
    """
    from circus.watcher import Watcher
    if background:
        from circus.arbiter import ThreadedArbiter as Arbiter   # NOQA
    else:
        from circus.arbiter import Arbiter   # NOQA

    _watchers = []

    for watcher in watchers:
        cmd = watcher['cmd']
        name = watcher.get('name', os.path.basename(cmd.split()[0]))

        watcher = Watcher(name,
                          cmd,
                          watcher.get('numprocesses', 1),
                          working_dir=watcher.get('working_dir'),
                          warmup_delay=float(watcher.get('warmup_delay', '0')),
                          shell=watcher.get('shell'),
                          uid=watcher.get('uid'),
                          gid=watcher.get('gid'),
                          env=watcher.get('env'))
        _watchers.append(watcher)

    return Arbiter(_watchers, controller, pubsub_endpoint, context=context,
                   check_flapping=check_flapping)
开发者ID:sakti,项目名称:circus,代码行数:59,代码来源:__init__.py


注:本文中的circus.watcher.Watcher.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。