本文整理汇总了Python中circus.arbiter.Arbiter.start方法的典型用法代码示例。如果您正苦于以下问题:Python Arbiter.start方法的具体用法?Python Arbiter.start怎么用?Python Arbiter.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circus.arbiter.Arbiter
的用法示例。
在下文中一共展示了Arbiter.start方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_start_with_callback
# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import start [as 别名]
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)
示例2: test_start_arbiter_with_autostart
# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import start [as 别名]
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()
示例3: test_start_arbiter_with_autostart
# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import start [as 别名]
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()
示例4: test_add_watcher
# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import start [as 别名]
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()
示例5: test_circushttpd
# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import start [as 别名]
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()
示例6: test_circushttpd
# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import start [as 别名]
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()
示例7: test_start_with_callback_and_given_loop
# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import start [as 别名]
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)
示例8: int
# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import start [as 别名]
limit = cfg_name[7:]
rlimits[limit] = int(cfg_value)
watcher = Watcher(name, cmd, numprocesses=numprocesses,
warmup_delay=warmup_delay, working_dir=working_dir,
shell=shell, uid=uid, gid=gid, send_hup=send_hup,
times=times, within=within, retry_in=retry_in,
max_retry=max_retry, graceful_timeout=graceful_timeout,
rlimits=rlimits)
watchers.append(watcher)
# main circus options
check = cfg.dget('circus', 'check_delay', 5, int)
endpoint = cfg.dget('circus', 'endpoint', 'tcp://127.0.0.1:5555')
pubsub_endpoint = cfg.dget('circus', 'pubsub_endpoint',
'tcp://127.0.0.1:5556')
arbiter = Arbiter(watchers, endpoint, pubsub_endpoint, check)
try:
arbiter.start()
finally:
arbiter.stop()
if pidfile is not None:
pidfile.unlink()
sys.exit(0)
if __name__ == '__main__':
main()
示例9: main
# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import start [as 别名]
def main():
#configure_logger(logger, 'DEBUG')
config_mod = 'circus_settings'
if len(sys.argv) > 1:
config_mod = sys.argv[1]
config = import_module(config_mod)
for p in config.PATHS:
ap = os.path.abspath(p)
if ap not in os.sys.path:
os.sys.path.append(ap)
watchers = []
sockets = []
for s in config.SERVERS:
w = Watcher(gc(s, SERVER_NAME),
gc(s, SERVER_PROGRAM),
gc(s, SERVER_ARGS),
numprocesses=gc(s, SERVER_WORKERS, 1),
working_dir=gc(s, SERVER_WORKING_DIR, './'),
env=gc(s, SERVER_ENV, dict()),
copy_env=True,
copy_path=True,
use_sockets=True)
watchers.append(w)
sock_port = gc(s, SERVER_PORT)
if sock_port is not None:
sock_name = gc(s, SERVER_NAME)
sock_host = gc(s, SERVER_HOST, '127.0.0.1')
sock = CircusSocket(sock_name, host=sock_host, port=sock_port)
sockets.append(sock)
for sock in sockets:
print '>> %s'%(sock,)
try:
WANT_WEB = getattr(config, 'WANT_WEB')
except Exception:
WANT_WEB = True
if HAS_WEB and WANT_WEB:
arbiter = Arbiter(watchers, DEFAULT_ENDPOINT_DEALER, DEFAULT_ENDPOINT_SUB,
sockets=sockets,
stats_endpoint=DEFAULT_ENDPOINT_STATS,
multicast_endpoint=DEFAULT_ENDPOINT_MULTICAST,
statsd=True,
httpd=True,
httpd_port=9999)
else:
arbiter = Arbiter(watchers, DEFAULT_ENDPOINT_DEALER, DEFAULT_ENDPOINT_SUB,
sockets=sockets,
stats_endpoint=DEFAULT_ENDPOINT_STATS,
multicast_endpoint=DEFAULT_ENDPOINT_MULTICAST)
arbiter.start()