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


Python hub.kill函数代码示例

本文整理汇总了Python中ryu.lib.hub.kill函数的典型用法代码示例。如果您正苦于以下问题:Python kill函数的具体用法?Python kill怎么用?Python kill使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了kill函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ssl

 def test_ssl(self):
     """Tests SSL server functionality."""
     # TODO: TLS version enforcement is necessary to avoid
     # vulnerable versions. Currently, this only tests TLS
     # connectivity.
     this_dir = os.path.dirname(sys.modules[__name__].__file__)
     saved_exception = None
     try:
         ssl_version = ssl.PROTOCOL_TLS
     except AttributeError:
         # For compatibility with older pythons.
         ssl_version = ssl.PROTOCOL_TLSv1
     for i in range(3):
         try:
             # Try a few times as this can fail with EADDRINUSE
             port = random.randint(5000, 10000)
             server = hub.spawn(self._test_ssl, this_dir, port)
             hub.sleep(1)
             client = hub.StreamClient(("127.0.0.1", port),
                                       timeout=5,
                                       ssl_version=ssl_version)
             if client.connect() is not None:
                 break
         except Exception as e:
             saved_exception = e
             continue
         finally:
             try:
                 hub.kill(server)
             except Exception:
                 pass
     else:
         self.fail("Failed to connect: " + str(saved_exception))
开发者ID:osrg,项目名称:ryu,代码行数:33,代码来源:test_controller.py

示例2: stop

 def stop(self):
     super(GaugeThreadPoller, self).stop()
     self._running = False
     if self.is_active():
         hub.kill(self.thread)
         hub.joinall([self.thread])
         self.thread = None
开发者ID:gizmoguy,项目名称:faucet,代码行数:7,代码来源:gauge_pollers.py

示例3: close

 def close(self):
     if self.test_thread is not None:
         hub.kill(self.test_thread)
     if self.ingress_event:
         self.ingress_event.set()
     hub.joinall([self.test_thread])
     self._test_end('--- Test terminated ---')
开发者ID:paisa4ever,项目名称:ryu,代码行数:7,代码来源:tester.py

示例4: serve

    def serve(self):
        send_thr = hub.spawn(self._send_loop)

        try:
            self._recv_loop()
        finally:
            hub.kill(send_thr)
            hub.joinall([send_thr])
开发者ID:cannium,项目名称:openflow_routing_framework,代码行数:8,代码来源:bgp_server.py

示例5: set_querier_mode

 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:Huangmachi,项目名称:ryu,代码行数:9,代码来源:igmplib.py

示例6: serve

    def serve(self):
        send_thr = hub.spawn(self._send_loop)

        hello = self.oxproto_parser.OXPHello(self)
        self.send_msg(hello)

        try:
            self._recv_loop()
        finally:
            hub.kill(send_thr)
            hub.joinall([send_thr])
开发者ID:bigclouds,项目名称:ryu,代码行数:11,代码来源:oxp_super.py

示例7: delete

    def delete(self, pkt=None, del_addr=None):
        if pkt is not None:
            del_list = [pkt]
        else:
            assert del_addr is not None
            del_list = [pkt for pkt in self if pkt.dst_ip in del_addr]

        for pkt in del_list:
            self.remove(pkt)
            hub.kill(pkt.wait_thread)
            pkt.wait_thread.wait()
开发者ID:BenjaminUJun,项目名称:ryuo,代码行数:11,代码来源:router.py

示例8: serve

    def serve(self):
        send_thr = hub.spawn(self._send_loop)

        # send hello message immediately
        hello = self.ofproto_parser.OFPHello(self)
        self.send_msg(hello)

        try:
            self._recv_loop()
        finally:
            hub.kill(send_thr)
            hub.joinall([send_thr])
开发者ID:beba-eu,项目名称:beba-ctrl,代码行数:12,代码来源:controller.py

示例9: test_spawn_kill_die_joinall

    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:5g-empower,项目名称:empower-ryu,代码行数:14,代码来源:test_hub.py

示例10: _remove_from_queue

 def _remove_from_queue(self, rule_id):
     queue_head = True
     for time_period in self._rule_time_queue:
         for item in time_period:
             if item == rule_id:
                 time_period.remove(rule_id) 
                 # Was this the only rule being scheduled
                 # at rule_id's time?
                 if len(time_period) < 1:
                     self._rule_time_queue.remove(time_period)
                     if queue_head:
                         hub.kill(self._gthread_rule_dist)
                         self._gthread_rule_dist = hub.spawn(self._distribute_rules_time)
                 return
         queue_head = False
开发者ID:bakkerjarr,项目名称:NWEN402_2015_JarrodBakker_Project,代码行数:15,代码来源:acl_switch_stateful_snort.py

示例11: serve

    def serve(self):
        # TODO: entry point
        send_thr = hub.spawn(self._send_loop)

        # send hello message immediately
        #hello = self.ofproto_parser.OFPHello(self)
        #self.send_msg(hello)
        buf = "Server"
        self.socket.sendall(buf)

        try:
            self._recv_loop()
        finally:
            hub.kill(send_thr)
            hub.joinall([send_thr])
开发者ID:hu1uwa,项目名称:ryu,代码行数:15,代码来源:oxp_super.py

示例12: stop

    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:John-Thunder,项目名称:ryu,代码行数:15,代码来源:manager.py

示例13: test_spawn_kill_nowait_joinall

    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:5g-empower,项目名称:empower-ryu,代码行数:15,代码来源:test_hub.py

示例14: test_spawn_kill_joinall

    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:5g-empower,项目名称:empower-ryu,代码行数:16,代码来源:test_hub.py

示例15: serve

    def serve(self):
        send_thr = hub.spawn(self._send_loop)

        # send hello message immediately
        hello = self.ofproto_parser.OFPHello(self)
        self.send_msg(hello)

        echo_thr = hub.spawn(self._echo_request_loop)

        try:
            self._recv_loop()
        finally:
            hub.kill(send_thr)
            hub.kill(echo_thr)
            hub.joinall([send_thr, echo_thr])
            self.is_active = False
开发者ID:leftyLin,项目名称:ryu,代码行数:16,代码来源:controller.py


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