當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。