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


Python arbiter.Arbiter类代码示例

本文整理汇总了Python中circus.arbiter.Arbiter的典型用法代码示例。如果您正苦于以下问题:Python Arbiter类的具体用法?Python Arbiter怎么用?Python Arbiter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_start_arbiter_with_autostart

 def test_start_arbiter_with_autostart(self):
     arbiter = Arbiter([], DEFAULT_ENDPOINT_DEALER, DEFAULT_ENDPOINT_SUB,
                       loop=get_ioloop(),
                       check_delay=-1)
     arbiter.add_watcher('foo', SLEEP % 5, autostart=False)
     try:
         yield arbiter.start()
         self.assertEqual(arbiter.watchers[0].status(), 'stopped')
     finally:
         yield arbiter.stop()
开发者ID:aubustou,项目名称:circus,代码行数:10,代码来源:test_arbiter.py

示例2: test_start_arbiter_with_autostart

 def test_start_arbiter_with_autostart(self):
     arbiter = Arbiter([], DEFAULT_ENDPOINT_DEALER, DEFAULT_ENDPOINT_SUB,
                       loop=tornado.ioloop.IOLoop.instance(),
                       check_delay=-1)
     arbiter.add_watcher('foo', 'sleep 5', autostart=False)
     try:
         yield arbiter.start()
         self.assertEqual(arbiter.watchers[0].status(), 'stopped')
     finally:
         yield arbiter.stop()
开发者ID:bbinet,项目名称:circus,代码行数:10,代码来源:test_arbiter.py

示例3: test_add_watcher

 def test_add_watcher(self):
     controller = "tcp://127.0.0.1:%d" % get_available_port()
     sub = "tcp://127.0.0.1:%d" % get_available_port()
     arbiter = Arbiter([], controller, sub, loop=get_ioloop(),
                       check_delay=-1)
     arbiter.add_watcher('foo', SLEEP % 5)
     try:
         yield arbiter.start()
         self.assertEqual(arbiter.watchers[0].status(), 'active')
     finally:
         yield arbiter.stop()
开发者ID:aubustou,项目名称:circus,代码行数:11,代码来源:test_arbiter.py

示例4: test_circushttpd

 def test_circushttpd(self):
     arbiter = Arbiter([], DEFAULT_ENDPOINT_DEALER, DEFAULT_ENDPOINT_SUB,
                       loop=tornado.ioloop.IOLoop.instance(),
                       check_delay=-1, httpd=True, debug=True)
     self.arbiters.append(arbiter)
     try:
         yield arbiter.start()
         poll_for_callable(self.assertDictEqual,
                           arbiter.statuses, {'circushttpd': 'active'})
     finally:
         yield arbiter.stop()
开发者ID:bbinet,项目名称:circus,代码行数:11,代码来源:test_arbiter.py

示例5: test_circushttpd

    def test_circushttpd(self):
        controller = "tcp://127.0.0.1:%d" % get_available_port()
        sub = "tcp://127.0.0.1:%d" % get_available_port()

        arbiter = Arbiter([], controller, sub, loop=get_ioloop(),
                          check_delay=-1, httpd=True, debug=True)
        self.arbiters.append(arbiter)
        try:
            yield arbiter.start()
            poll_for_callable(self.assertDictEqual,
                              arbiter.statuses, {'circushttpd': 'active'})
        finally:
            yield arbiter.stop()
开发者ID:aubustou,项目名称:circus,代码行数:13,代码来源:test_arbiter.py

示例6: test_start_watchers_warmup_delay

    def test_start_watchers_warmup_delay(self):
        watcher = MockWatcher(name='foo', cmd='serve', priority=1)
        arbiter = Arbiter([], None, None, warmup_delay=10)
        with patch('circus.arbiter.sleep') as mock_sleep:
            arbiter.start_watcher(watcher)
            mock_sleep.assert_called_with(10)

        # now make sure we don't sleep when there is a autostart
        watcher = MockWatcher(name='foo', cmd='serve', priority=1,
                              autostart=False)
        with patch('circus.arbiter.sleep') as mock_sleep:
            arbiter.start_watcher(watcher)
            assert not mock_sleep.called
开发者ID:zerok,项目名称:circus,代码行数:13,代码来源:test_arbiter.py

示例7: test_start_with_callback

    def test_start_with_callback(self):
        controller = "tcp://127.0.0.1:%d" % get_available_port()
        sub = "tcp://127.0.0.1:%d" % get_available_port()
        arbiter = Arbiter([], controller, sub, check_delay=-1)

        callee = mock.MagicMock()

        def callback(*args):
            callee()
            arbiter.stop()

        arbiter.start(cb=callback)

        self.assertEqual(callee.call_count, 1)
开发者ID:aubustou,项目名称:circus,代码行数:14,代码来源:test_arbiter.py

示例8: test_start_with_callback_and_given_loop

    def test_start_with_callback_and_given_loop(self):
        controller = "tcp://127.0.0.1:%d" % get_available_port()
        sub = "tcp://127.0.0.1:%d" % get_available_port()
        arbiter = Arbiter([], controller, sub, check_delay=-1,
                          loop=get_ioloop())

        callback = mock.MagicMock()

        try:
            yield arbiter.start(cb=callback)
        finally:
            yield arbiter.stop()

        self.assertEqual(callback.call_count, 0)
开发者ID:aubustou,项目名称:circus,代码行数:14,代码来源:test_arbiter.py

示例9: _load_base_arbiter

 def _load_base_arbiter(self):
     a = Arbiter.load_from_config(_CONF['reload_base'])
     a.evpub_socket = FakeSocket()
     # initialize watchers
     for watcher in a.iter_watchers():
         a._watchers_names[watcher.name.lower()] = watcher
     return a
开发者ID:jsonkey,项目名称:circus,代码行数:7,代码来源:test_reloadconfig.py

示例10: setUp

    def setUp(self):
        conf = _CONF['reload_base']
        self.a = Arbiter.load_from_config(conf)
        self.a.evpub_socket = FakeSocket()

        # initialize watchers
        for watcher in self.a.iter_watchers():
            self.a._watchers_names[watcher.name.lower()] = watcher
开发者ID:EnTeQuAk,项目名称:circus,代码行数:8,代码来源:test_reloadconfig.py

示例11: _load_base_arbiter

 def _load_base_arbiter(self, name='reload_base'):
     loop = tornado.ioloop.IOLoop().instance()
     a = Arbiter.load_from_config(_CONF[name], loop=loop)
     a.evpub_socket = FakeSocket()
     # initialize watchers
     for watcher in a.iter_watchers():
         a._watchers_names[watcher.name.lower()] = watcher
     return a
开发者ID:amarandon,项目名称:circus,代码行数:8,代码来源:test_reloadconfig.py

示例12: test_plugin_priority

 def test_plugin_priority(self):
     arbiter = Arbiter.load_from_config(_CONF['issue680'])
     watchers = arbiter.iter_watchers()
     self.assertEqual(watchers[0].priority, 30)
     self.assertEqual(watchers[0].name, 'plugin:myplugin')
     self.assertEqual(watchers[1].priority, 20)
     self.assertEqual(watchers[1].cmd, 'sleep 20')
     self.assertEqual(watchers[2].priority, 10)
     self.assertEqual(watchers[2].cmd, 'sleep 10')
开发者ID:SEJeff,项目名称:circus,代码行数:9,代码来源:test_config.py

示例13: main

def main():
    parser = argparse.ArgumentParser(description='Run some watchers.')
    parser.add_argument('config', help='configuration file', nargs='?')

    # XXX we should be able to add all these options in the config file as well
    parser.add_argument('--log-level', dest='loglevel',
                        choices=LOG_LEVELS.keys() + [key.upper() for key in
                                                     LOG_LEVELS.keys()],
                        help="log level")
    parser.add_argument('--log-output', dest='logoutput', help=(
        "The location where the logs will be written. The default behavior "
        "is to write to stdout (you can force it by passing '-' to "
        "this option). Takes a filename otherwise."))

    parser.add_argument('--daemon', dest='daemonize', action='store_true',
                        help="Start circusd in the background")
    parser.add_argument('--pidfile', dest='pidfile')
    parser.add_argument('--version', action='store_true', default=False,
                        help='Displays Circus version and exits.')

    args = parser.parse_args()

    if args.version:
        print(__version__)
        sys.exit(0)

    if args.config is None:
        parser.print_usage()
        sys.exit(0)

    if args.daemonize:
        daemonize()

    # basic logging configuration
    logging.basicConfig()

    # From here it can also come from the arbiter configuration
    # load the arbiter from config
    arbiter = Arbiter.load_from_config(args.config)

    pidfile = args.pidfile or arbiter.pidfile or None
    if pidfile:
        pidfile = Pidfile(pidfile)

        try:
            pidfile.create(os.getpid())
        except RuntimeError, e:
            print(str(e))
            sys.exit(1)
开发者ID:strategist922,项目名称:circus,代码行数:49,代码来源:circusd.py

示例14: test_reload

    def test_reload(self):
        a = Arbiter.load_from_config(_CONF["reload1"])
        a.initialize()
        self.assertEqual(len(a.watchers), 1)
        a.reload_from_config(_CONF["reload2"])
        self.assertEqual(len(a.watchers), 2)
        a.reload_from_config(_CONF["reload3"])
        self.assertEqual(len(a.watchers), 1)

        a.reload_from_config(_CONF["reload4"])
        self.assertEqual(len(a.watchers), 1)
        self.assertEqual(a.watchers[0].name, "test3")
        self.assertEqual(a.watchers[0].numprocesses, 1)
        w = a.watchers[0]
        a.reload_from_config(_CONF["reload5"])
        self.assertEqual(a.watchers[0].name, "test3")
        self.assertEqual(a.watchers[0].numprocesses, 2)

        # check that just the number of processes is changed and that the watcher it self is not changed
        self.assertEqual(a.watchers[0], w)

        a.evpub_socket.close()
        a.stop()
开发者ID:Jud,项目名称:circus,代码行数:23,代码来源:test_reloadconfig.py

示例15: test_find_hook_in_pythonpath

 def test_find_hook_in_pythonpath(self):
     arbiter = Arbiter.load_from_config(_CONF['find_hook_in_pythonpath'])
     watcher = arbiter.iter_watchers()[0]
     self.assertEqual(watcher.hooks['before_start'].__doc__,
                      'relative_hook')
     self.assertTrue('before_start' not in watcher.ignore_hook_failure)
开发者ID:aubustou,项目名称:circus,代码行数:6,代码来源:test_config.py


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