当前位置: 首页>>代码示例>>Python>>正文


Python hub.kill方法代码示例

本文整理汇总了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 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:18,代码来源:test_hub.py

示例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() 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:23,代码来源:app_manager.py

示例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) 
开发者ID:PacktPublishing,项目名称:Mastering-Python-Networking,代码行数:7,代码来源:chapter13_router_1.py

示例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 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:11,代码来源:igmplib.py

示例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 )
    # ------------------------------------------------------------------- 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:12,代码来源:igmplib.py

示例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 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:7,代码来源:stplib.py

示例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) 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:10,代码来源:tester.py

示例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]) 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:5,代码来源:test_rpc.py

示例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 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:17,代码来源:test_hub.py

示例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 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:16,代码来源:test_hub.py

示例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) 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:8,代码来源:app_manager.py

示例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() 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:17,代码来源:manager.py

示例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() 
开发者ID:thanh-nguyen-dang,项目名称:ez-segway,代码行数:6,代码来源:central_ctrl.py

示例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) 
开发者ID:thanh-nguyen-dang,项目名称:ez-segway,代码行数:32,代码来源:central_ctrl.py


注:本文中的ryu.lib.hub.kill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。