本文整理汇总了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()
示例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()
示例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()
示例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()
示例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()
示例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
示例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)
示例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)
示例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
示例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
示例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
示例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')
示例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)
示例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()
示例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)