本文整理汇总了Python中circus.sockets.CircusSockets.bind_and_listen_all方法的典型用法代码示例。如果您正苦于以下问题:Python CircusSockets.bind_and_listen_all方法的具体用法?Python CircusSockets.bind_and_listen_all怎么用?Python CircusSockets.bind_and_listen_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circus.sockets.CircusSockets
的用法示例。
在下文中一共展示了CircusSockets.bind_and_listen_all方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unix_cleanup
# 需要导入模块: from circus.sockets import CircusSockets [as 别名]
# 或者: from circus.sockets.CircusSockets import bind_and_listen_all [as 别名]
def test_unix_cleanup(self):
sockets = CircusSockets()
sockfile = self._get_tmp_filename()
try:
sockets.add('unix', path=sockfile)
sockets.bind_and_listen_all()
self.assertTrue(os.path.exists(sockfile))
finally:
sockets.close_all()
self.assertTrue(not os.path.exists(sockfile))
示例2: test_manager
# 需要导入模块: from circus.sockets import CircusSockets [as 别名]
# 或者: from circus.sockets.CircusSockets import bind_and_listen_all [as 别名]
def test_manager(self):
mgr = CircusSockets()
for i in range(5):
mgr.add(str(i), 'localhost', 0)
port = mgr['1'].port
try:
mgr.bind_and_listen_all()
# we should have a port now
self.assertNotEqual(port, mgr['1'].port)
finally:
mgr.close_all()
示例3: test_unix_cleanup
# 需要导入模块: from circus.sockets import CircusSockets [as 别名]
# 或者: from circus.sockets.CircusSockets import bind_and_listen_all [as 别名]
def test_unix_cleanup(self):
sockets = CircusSockets()
fd, sockfile = tempfile.mkstemp()
os.close(fd)
os.remove(sockfile)
try:
sockets.add('unix', path=sockfile)
sockets.bind_and_listen_all()
self.assertTrue(os.path.exists(sockfile))
finally:
sockets.close_all()
self.assertTrue(not os.path.exists(sockfile))
示例4: Arbiter
# 需要导入模块: from circus.sockets import CircusSockets [as 别名]
# 或者: from circus.sockets.CircusSockets import bind_and_listen_all [as 别名]
#.........这里部分代码省略.........
# creating arbiter
arbiter = cls(
watchers,
cfg["endpoint"],
cfg["pubsub_endpoint"],
check_delay=cfg.get("check_delay", 1.0),
prereload_fn=cfg.get("prereload_fn"),
stats_endpoint=cfg.get("stats_endpoint"),
plugins=cfg.get("plugins"),
sockets=sockets,
)
return arbiter
def iter_watchers(self):
watchers = [(watcher.priority, watcher) for watcher in self.watchers]
watchers.sort()
watchers.reverse()
for __, watcher in watchers:
yield watcher
@debuglog
def initialize(self):
# set process title
_setproctitle("circusd")
# event pub socket
self.evpub_socket = self.context.socket(zmq.PUB)
self.evpub_socket.bind(self.pubsub_endpoint)
self.evpub_socket.linger = 0
# initialize sockets
if len(self.sockets) > 0:
self.sockets.bind_and_listen_all()
logger.info("sockets started")
# initialize watchers
for watcher in self.iter_watchers():
self._watchers_names[watcher.name.lower()] = watcher
watcher.initialize(self.evpub_socket, self.sockets)
@debuglog
def start(self):
"""Starts all the watchers.
The start command is an infinite loop that waits
for any command from a client and that watches all the
processes and restarts them if needed.
"""
logger.info("Starting master on pid %s", self.pid)
self.initialize()
# start controller
self.ctrl.start()
# initialize processes
logger.debug("Initializing watchers")
for watcher in self.iter_watchers():
watcher.start()
logger.info("Arbiter now waiting for commands")
while True:
try:
self.loop.start()
except zmq.ZMQError as e:
示例5: Arbiter
# 需要导入模块: from circus.sockets import CircusSockets [as 别名]
# 或者: from circus.sockets.CircusSockets import bind_and_listen_all [as 别名]
#.........这里部分代码省略.........
loglevel=cfg.get('loglevel', None),
logoutput=cfg.get('logoutput', None),
loggerconfig=cfg.get('loggerconfig', None),
fqdn_prefix=cfg.get('fqdn_prefix', None),
umask=cfg['umask'],
endpoint_owner=cfg.get('endpoint_owner', None))
# store the cfg which will be used, so it can be used later
# for checking if the cfg has been changed
arbiter._cfg = cls.get_arbiter_config(cfg)
arbiter.config_file = config_file
return arbiter
def iter_watchers(self, reverse=True):
return sorted(self.watchers, key=lambda a: a.priority, reverse=reverse)
@debuglog
def initialize(self):
# set process title
_setproctitle(self.proc_name)
# set umask even though we may have already set it early in circusd.py
if self.umask is not None:
os.umask(self.umask)
# event pub socket
self.evpub_socket = self.context.socket(zmq.PUB)
self.evpub_socket.bind(self.pubsub_endpoint)
self.evpub_socket.linger = 0
# initialize sockets
if len(self.sockets) > 0:
self.sockets.bind_and_listen_all()
logger.info("sockets started")
# initialize watchers
for watcher in self.iter_watchers():
self._watchers_names[watcher.name.lower()] = watcher
watcher.initialize(self.evpub_socket, self.sockets, self)
@gen.coroutine
def start_watcher(self, watcher):
"""Aska a specific watcher to start and wait for the specified
warmup delay."""
if watcher.autostart:
yield watcher._start()
yield tornado_sleep(self.warmup_delay)
@gen.coroutine
@debuglog
def start(self):
"""Starts all the watchers.
If the ioloop has been provided during __init__() call,
starts all watchers as a standard coroutine
If the ioloop hasn't been provided during __init__() call (default),
starts all watchers and the eventloop (and blocks here). In this mode
the method MUST NOT yield anything because it's called as a standard
method.
"""
logger.info("Starting master on pid %s", self.pid)
self.initialize()
# start controller
示例6: Arbiter
# 需要导入模块: from circus.sockets import CircusSockets [as 别名]
# 或者: from circus.sockets.CircusSockets import bind_and_listen_all [as 别名]
#.........这里部分代码省略.........
arbiter = cls(watchers, cfg['endpoint'], cfg['pubsub_endpoint'],
check_delay=cfg.get('check_delay', 1.),
prereload_fn=cfg.get('prereload_fn'),
stats_endpoint=cfg.get('stats_endpoint'),
plugins=cfg.get('plugins'), sockets=sockets,
warmup_delay=cfg.get('warmup_delay', 0),
httpd=cfg.get('httpd', False),
httpd_host=cfg.get('httpd_host', 'localhost'),
httpd_port=cfg.get('httpd_port', 8080),
debug=cfg.get('debug', False),
stream_backend=cfg.get('stream_backend', 'thread'),
ssh_server=cfg.get('ssh_server', None))
return arbiter
def iter_watchers(self, reverse=True):
watchers = [(watcher.priority, watcher) for watcher in self.watchers]
watchers.sort(reverse=reverse)
for __, watcher in watchers:
yield watcher
@debuglog
def initialize(self):
# set process title
_setproctitle(self.proc_name)
# event pub socket
self.evpub_socket = self.context.socket(zmq.PUB)
self.evpub_socket.bind(self.pubsub_endpoint)
self.evpub_socket.linger = 0
# initialize sockets
if len(self.sockets) > 0:
self.sockets.bind_and_listen_all()
logger.info("sockets started")
# initialize watchers
for watcher in self.iter_watchers():
self._watchers_names[watcher.name.lower()] = watcher
watcher.initialize(self.evpub_socket, self.sockets, self)
@debuglog
def start(self):
"""Starts all the watchers.
The start command is an infinite loop that waits
for any command from a client and that watches all the
processes and restarts them if needed.
"""
logger.info("Starting master on pid %s", self.pid)
self.initialize()
# start controller
self.ctrl.start()
try:
# initialize processes
logger.debug('Initializing watchers')
for watcher in self.iter_watchers():
watcher.start()
time.sleep(self.warmup_delay)
logger.info('Arbiter now waiting for commands')
while True:
示例7: Arbiter
# 需要导入模块: from circus.sockets import CircusSockets [as 别名]
# 或者: from circus.sockets.CircusSockets import bind_and_listen_all [as 别名]
#.........这里部分代码省略.........
httpd_host=cfg.get('httpd_host', 'localhost'),
httpd_port=cfg.get('httpd_port', 8080),
debug=cfg.get('debug', False),
ssh_server=cfg.get('ssh_server', None),
pidfile=cfg.get('pidfile', None),
loglevel=cfg.get('loglevel', None),
logoutput=cfg.get('logoutput', None))
# store the cfg which will be used, so it can be used later
# for checking if the cfg has been changed
arbiter._cfg = cls.get_arbiter_config(cfg)
arbiter.config_file = config_file
return arbiter
def iter_watchers(self, reverse=True):
watchers = [(watcher.priority, watcher) for watcher in self.watchers]
watchers.sort(reverse=reverse)
for __, watcher in watchers:
yield watcher
@debuglog
def initialize(self):
# set process title
_setproctitle(self.proc_name)
# event pub socket
self.evpub_socket = self.context.socket(zmq.PUB)
self.evpub_socket.bind(self.pubsub_endpoint)
self.evpub_socket.linger = 0
# initialize sockets
if len(self.sockets) > 0:
self.sockets.bind_and_listen_all()
logger.info("sockets started")
# initialize watchers
for watcher in self.iter_watchers():
self._watchers_names[watcher.name.lower()] = watcher
watcher.initialize(self.evpub_socket, self.sockets, self)
def start_watcher(self, watcher):
"""Aska a specific watcher to start and wait for the specified
warmup delay."""
if watcher.autostart:
watcher.start()
sleep(self.warmup_delay)
@debuglog
def start(self):
"""Starts all the watchers.
The start command is an infinite loop that waits
for any command from a client and that watches all the
processes and restarts them if needed.
"""
logger.info("Starting master on pid %s", self.pid)
self.initialize()
# start controller
self.ctrl.start()
try:
# initialize processes
logger.debug('Initializing watchers')
for watcher in self.iter_watchers():
self.start_watcher(watcher)