本文整理汇总了Python中ryu.lib.hub.kill方法的典型用法代码示例。如果您正苦于以下问题:Python hub.kill方法的具体用法?Python hub.kill怎么用?Python hub.kill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ryu.lib.hub
的用法示例。
在下文中一共展示了hub.kill方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_spawn_kill_joinall
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def test_spawn_kill_joinall(self):
def _child(ev2, result):
ev2.wait()
result.append(1)
ev2 = hub.Event()
threads = []
result = []
with hub.Timeout(2):
threads.append(hub.spawn(_child, ev2, result))
threads.append(hub.spawn(_child, ev2, result))
hub.sleep(0.5)
for t in threads:
hub.kill(t)
hub.joinall(threads)
assert len(result) == 0
示例2: run_apps
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def run_apps(app_lists):
"""Run a set of Ryu applications
A convenient method to load and instantiate apps.
This blocks until all relevant apps stop.
"""
app_mgr = AppManager.get_instance()
app_mgr.load_apps(app_lists)
contexts = app_mgr.create_contexts()
services = app_mgr.instantiate_apps(**contexts)
webapp = wsgi.start_service(app_mgr)
if webapp:
services.append(hub.spawn(webapp))
try:
hub.joinall(services)
finally:
app_mgr.close()
for t in services:
t.kill()
hub.joinall(services)
gc.collect()
示例3: delete
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def delete(self):
hub.kill(self.thread)
self.thread.wait()
self.logger.info('Stop cyclic routing table update.',
extra=self.sw_id)
示例4: set_querier_mode
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def set_querier_mode(self, dpid, server_port):
"""set the datapath to work as a querier. note that you can set
up only the one querier. when you called this method several
times, only the last one becomes effective."""
self.dpid = dpid
self.server_port = server_port
if self._querier_thread:
hub.kill(self._querier_thread)
self._querier_thread = None
示例5: stop_loop
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def stop_loop(self):
"""stop QUERY thread."""
hub.kill(self._querier_thread)
self._querier_thread = None
self._datapath = None
self.logger.info("stopped a querier.")
# -------------------------------------------------------------------
# PRIVATE METHODS ( RELATED TO IGMP )
# -------------------------------------------------------------------
示例6: stop
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def stop(self):
if self.thread is not None:
hub.kill(self.thread)
hub.joinall([self.thread])
self.thread = None
示例7: _test_end
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def _test_end(self, msg=None, report=None):
self.test_thread = None
if msg:
self.logger.info(msg)
if report:
self._output_test_report(report)
pid = os.getpid()
os.kill(pid, signal.SIGTERM)
示例8: tearDown
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def tearDown(self):
hub.kill(self._server_thread)
hub.joinall([self._server_thread])
示例9: test_spawn_kill_nowait_joinall
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def test_spawn_kill_nowait_joinall(self):
# XXX this test relies on the scheduling behaviour.
# the intention here is, killing threads before they get active.
def _child(result):
result.append(1)
threads = []
result = []
with hub.Timeout(2):
threads.append(hub.spawn(_child, result))
for t in threads:
hub.kill(t)
hub.joinall(threads)
assert len(result) == 0
示例10: test_spawn_kill_die_joinall
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def test_spawn_kill_die_joinall(self):
def _child(result):
result.append(1)
threads = []
result = []
with hub.Timeout(2):
threads.append(hub.spawn(_child, result))
threads.append(hub.spawn(_child, result))
hub.sleep(0.5)
for t in threads:
hub.kill(t)
hub.joinall(threads)
assert len(result) == 2
示例11: stop
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def stop(self):
if self.main_thread:
hub.kill(self.main_thread)
self.is_active = False
self._send_event(self._event_stop, None)
hub.joinall(self.threads)
示例12: stop
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def stop(self):
# NOTE(jkoelker) Attempt to gracefully stop the accept loop
self.is_active = False
# NOTE(jkoelker) Forceably kill the loop and clear the main_thread
if self.main_thread:
hub.kill(self.main_thread)
self.main_thread = None
# NOTE(jkoelker) Stop all the clients
for c in self._clients.values():
c.stop()
# NOTE(jkoelker) super will only take care of the event and joining now
super(OVSDB, self).stop()
示例13: delete
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def delete(self):
if self.thread is not None:
hub.kill(self.thread)
self.thread.wait()
示例14: do_when_finish
# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import kill [as 别名]
def do_when_finish(self, encounter_deadlock):
finished_time = time() * 1000
finish_time_from_start = finished_time - self.current_start_time
finish_time_from_last_sending = finished_time - self.current_finish_sending_time
total_sending_time = self.current_finish_sending_time - self.current_sending_time
update_only_time = (finish_time_from_start - self.current_dependency_graph_cal)
max_delay = max(global_vars.sw_to_ctrl_delays)
self.handler.scheduler.trace.convert_to_time_from_starting(self.current_finish_sending_time,
self.current_sending_time - self.current_start_time
+ max_delay
)
log.info("test-%d: %f\t%d\t%f\t%f\t%f\t%f\t%d\t%s" %
(self.test_number - 1, finish_time_from_start, 0,
self.current_dependency_graph_cal, update_only_time,
finish_time_from_last_sending, total_sending_time,
self.handler.message_count * 2, encounter_deadlock))
log.info("test-%d-new_path: %s" % ((self.test_number - 1),
self.handler.scheduler.trace.times_using_new_path_to_string()))
# log.info("calculating time: %d ms" % self.current_dependency_graph_cal)
# log.info("finished after %s ms from sending" % (finish_time_from_sending * 1000))
if self.test_number < 1000:
hub.spawn_after(1, self._cyclic_update)
else:
os.kill(os.getpid(), signal.SIGTERM)
return
# if self.current_controller_sw < len(global_vars.switch_ids) - 1:
# self.current_controller_sw += 1
# self.test_number = 0
# self.ez_topo.deploy_controller(self.current_controller_sw, global_vars.sw_to_ctrl_delays)
# hub.spawn_after(1, self._cyclic_update)