• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python hub.kill函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: handle_role_upgrade

    def handle_role_upgrade(self):
        LOGGER.info("Upgrade to master")
        hub.kill(self.thread_pkt)
        while self.pkt_queue.__len__() > 0:
            self.consume_pkt()

        dcenters = self.inception.rpc_manager.get_dcenters()
        self.init_dcenter(dcenters)
        self.load_data(arp_manager=self.inception.arp_manager,
                       switch_manager=self.inception.switch_manager,
                       vm_manager=self.inception.vm_manager,
                       vmac_manager=self.inception.vmac_manager,
                       tenant_manager=self.inception.tenant_manager)
        self.handle_failover_log()
        self.master_ctl = True
        # TODO: New leader election design
        while True:
            time.sleep(1)
开发者ID:powerist,项目名称:ryu,代码行数:18,代码来源:inception_util.py


示例17: sched_remove_rule

    def sched_remove_rule(self, rule_id):
        """Remove a rule from the time queue.

        :param rule_id: ID of the rule to remove from the queue.
        :return: True if successful, False otherwise.
        """
        # The first iteration is through elements in head of the queue.
        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)
                    # time_period should be removed if rule_id was the
                    # only one scheduled at the time.
                    if len(time_period) < 1:
                        self._rule_time_queue.remove(time_period)
                        if queue_head:
                            # If the rule was at the head of the queue
                            # then we need to respawn the green thread.
                            hub.kill(self._rule_deploy_gthread)
                            self._rule_deploy_gthread = hub.spawn(
                                self._rule_deploy_alarm)
                    return True
            queue_head = False
开发者ID:bakkerjarr,项目名称:ACLSwitch,代码行数:24,代码来源:flow_scheduler.py


示例18: stop

 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:alanquillin,项目名称:ryu,代码行数:6,代码来源:app_manager.py


示例19: close

 def close(self):
     # self._rpc_daemon.shutdown()
     for thread in self.threads:
         hub.kill(thread)
开发者ID:BenjaminUJun,项目名称:ryuo,代码行数:4,代码来源:central.py


示例20: sched_add_rule

    def sched_add_rule(self, rule_id, time_enforce):
        """Insert a rule into the time queue for scheduling.

        :param rule_id: ID of the rule to schedule.
        :param time_enforce: A tuple of deployment time (24hr format)
        and enforcement duration (in seconds). Assumes that a rule can
        only be scheduled for one deployment time. Multiple times will
        be supported later.
        :return: True if successful, False otherwise.
        """
        if len(self._rule_time_queue) < 1:
            # Queue is empty so just insert the rule at the head
            self._rule_time_queue.append([rule_id])
            # Start a green thread to distribute time-based rules
            self._rule_deploy_gthread = hub.spawn(
                self._rule_deploy_alarm)
            return True

        # The queue is not empty so proceed...
        queue_head_id = self._rule_time_queue[0][0]
        queue_head_rule = self._api.acl_get_rule(queue_head_id)
        queue_head_time = dt.datetime.strptime(
            queue_head_rule.time_enforce[0], "%H:%M")
        rule_time = dt.datetime.strptime(time_enforce[0], "%H:%M")

        # Get the current time and normalise it
        cur_time = dt.datetime.strptime(
            dt.datetime.now().strftime("%H:%M"),
            "%H:%M")

        # Check if the queue head needs to be pre-empted
        if ((cur_time < queue_head_time and cur_time < rule_time <
            queue_head_time) or (queue_head_time < cur_time <
            rule_time) or (rule_time < queue_head_time < cur_time
            and rule_time < cur_time)):
            self._rule_time_queue.insert(0, [rule_id])
            hub.kill(self._rule_deploy_gthread)
            self._rule_deploy_gthread = hub.spawn(
                self._rule_deploy_alarm)
            return True

        # The rule needs to be inserted elsewhere in the queue
        len_queue = len(self._rule_time_queue)
        new_rule_time_store = rule_time
        for i in range(len_queue):
            # Reset any changes made by timedelta
            rule_time = new_rule_time_store

            rule_i = self._api.acl_get_rule(self._rule_time_queue[i][0])
            rule_i_time = dt.datetime.strptime(rule_i.time_enforce[0],
                                               "%H:%M")

            if rule_time == rule_i_time:
                self._rule_time_queue[i].append(rule_id)
                break

            if i == (len_queue - 1):
                # We have reached the end of the queue
                self._rule_time_queue.append([rule_id])
                break

            if rule_time < cur_time and rule_i_time > rule_time:
                # The new rule has a 'smaller' time value than the
                # current time but its time for scheduling has already
                # passed. This means that the rule should be scheduled
                # for tomorrow. To correct the comparisons we'll add a
                # day onto the datetime value.
                rule_time = rule_time + dt.timedelta(1)

            if i == 0 and rule_time < rule_i_time:
                self._rule_time_queue.insert(0, [rule_id])
                break

            rule_j = self._api.acl_get_rule(self._rule_time_queue[
                                                i+1][0])
            rule_j_time = dt.datetime.strptime(rule_j.time_enforce[0],
                                               "%H:%M")

            if rule_j_time < rule_i_time:
                # rule_j_time may be smaller than rule_i_time but it
                # may be scheduled for tomorrow.
                rule_j_time = rule_j_time + dt.timedelta(1)

            if rule_i_time < rule_time < rule_j_time:
                self._rule_time_queue.insert(i + 1, [rule_id])
                break
        return True
开发者ID:bakkerjarr,项目名称:ACLSwitch,代码行数:87,代码来源:flow_scheduler.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python hub.sleep函数代码示例发布时间:2022-05-27
下一篇:
Python hub.joinall函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap