本文整理汇总了Python中circus.sockets.CircusSockets.close_all方法的典型用法代码示例。如果您正苦于以下问题:Python CircusSockets.close_all方法的具体用法?Python CircusSockets.close_all怎么用?Python CircusSockets.close_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circus.sockets.CircusSockets
的用法示例。
在下文中一共展示了CircusSockets.close_all方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unix_cleanup
# 需要导入模块: from circus.sockets import CircusSockets [as 别名]
# 或者: from circus.sockets.CircusSockets import close_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 close_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 close_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 close_all [as 别名]
#.........这里部分代码省略.........
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:
if e.errno == errno.EINTR:
continue
else:
raise
else:
break
self.ctrl.stop()
self.evpub_socket.close()
def stop(self):
if self.alive:
self.stop_watchers(stop_alive=True)
self.loop.stop()
# close sockets
self.sockets.close_all()
def reap_processes(self):
# map watcher to pids
watchers_pids = {}
for watcher in self.iter_watchers():
if not watcher.stopped:
for process in watcher.processes.values():
watchers_pids[process.pid] = watcher
# detect dead children
while True:
try:
# wait for our child (so it's not a zombie)
pid, status = os.waitpid(-1, os.WNOHANG)
if not pid:
break
if pid in watchers_pids:
watcher = watchers_pids[pid]
watcher.reap_process(pid, status)
except OSError as e:
if e.errno == errno.EAGAIN:
time.sleep(0.001)
continue
elif e.errno == errno.ECHILD:
# process already reaped
return
else:
raise
def manage_watchers(self):
if not self.alive:
示例5: Arbiter
# 需要导入模块: from circus.sockets import CircusSockets [as 别名]
# 或者: from circus.sockets.CircusSockets import close_all [as 别名]
#.........这里部分代码省略.........
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
self.ctrl.start()
self._restarting = False
try:
# initialize processes
logger.debug('Initializing watchers')
if self._provided_loop:
yield self.start_watchers()
else:
# start_watchers will be called just after the start_io_loop()
self.loop.add_future(self.start_watchers(), lambda x: None)
logger.info('Arbiter now waiting for commands')
self._running = True
if not self._provided_loop:
# If an event loop is not provided, block at this line
self.start_io_loop()
finally:
if not self._provided_loop:
# If an event loop is not provided, do some cleaning
self.stop_controller_and_close_sockets()
raise gen.Return(self._restarting)
def stop_controller_and_close_sockets(self):
self.ctrl.stop()
self.evpub_socket.close()
if len(self.sockets) > 0:
self.sockets.close_all()
self._running = False
def start_io_loop(self):
"""Starts the ioloop and wait inside it
"""
while True:
try:
self.loop.start()
except zmq.ZMQError as e:
if e.errno == errno.EINTR:
continue
else:
raise
else:
break
@synchronized("arbiter_stop")
@gen.coroutine
def stop(self):
yield self._stop()
@gen.coroutine
def _emergency_stop(self):
"""Emergency and fast stop, to use only in circusd
"""
for watcher in self.iter_watchers():
watcher.graceful_timeout = 0
yield self._stop_watchers()
self.stop_controller_and_close_sockets()
@gen.coroutine
示例6: Arbiter
# 需要导入模块: from circus.sockets import CircusSockets [as 别名]
# 或者: from circus.sockets.CircusSockets import close_all [as 别名]
#.........这里部分代码省略.........
# 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:
try:
self.loop.start()
except zmq.ZMQError as e:
if e.errno == errno.EINTR:
continue
else:
raise
else:
break
finally:
self.ctrl.stop()
self.evpub_socket.close()
def stop(self):
if self.alive:
self.stop_watchers(stop_alive=True)
self.loop.stop()
# close sockets
self.sockets.close_all()
def reap_processes(self):
# map watcher to pids
watchers_pids = {}
for watcher in self.iter_watchers():
if not watcher.stopped:
for process in watcher.processes.values():
watchers_pids[process.pid] = watcher
# detect dead children
while True:
try:
# wait for our child (so it's not a zombie)
pid, status = os.waitpid(-1, os.WNOHANG)
if not pid:
break
if pid in watchers_pids:
watcher = watchers_pids[pid]
watcher.reap_process(pid, status)
except OSError as e:
if e.errno == errno.EAGAIN:
time.sleep(0.001)
continue
elif e.errno == errno.ECHILD:
# process already reaped
return
else:
raise
def manage_watchers(self):
if not self.alive:
示例7: Arbiter
# 需要导入模块: from circus.sockets import CircusSockets [as 别名]
# 或者: from circus.sockets.CircusSockets import close_all [as 别名]
#.........这里部分代码省略.........
"""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)
logger.info('Arbiter now waiting for commands')
while True:
try:
self.loop.start()
except zmq.ZMQError as e:
if e.errno == errno.EINTR:
continue
else:
raise
else:
break
finally:
self.ctrl.stop()
self.evpub_socket.close()
if len(self.sockets) > 0:
self.sockets.close_all()
def stop(self):
self.stop_watchers(stop_alive=True)
# this will stop the loop and the closing
# will finish in .start()
self.loop.stop()
def reap_processes(self):
# map watcher to pids
watchers_pids = {}
for watcher in self.iter_watchers():
if not watcher.stopped:
for process in watcher.processes.values():
watchers_pids[process.pid] = watcher
# detect dead children
while True:
try:
# wait for our child (so it's not a zombie)
pid, status = os.waitpid(-1, os.WNOHANG)
if not pid:
break
if pid in watchers_pids:
watcher = watchers_pids[pid]
watcher.reap_process(pid, status)
except OSError as e:
if e.errno == errno.EAGAIN:
sleep(0)
continue
elif e.errno == errno.ECHILD:
# process already reaped