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

Python hub.sleep函数代码示例

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

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



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

示例1: lldp_loop

    def lldp_loop(self):
        """
        This function is how the topology is kept up to date.
        It will send out LLDP packets at every interval to
        update the topology.
        """
        while self.is_active:
	    self.lldp_event.clear()
            now = time.time()
            timeout = None
            ports_now = []
            ports = []
            for (key, data) in self.ports.items():
                if data.timestamp is None:
                    ports_now.append(key)
                    continue

                expire = data.timestamp + self.LLDP_SEND_PERIOD_PER_PORT
                if expire <= now:
                    ports.append(key)
                    continue

                timeout = expire - now
                break

            for port in ports_now:
                self.send_lldp_packet(port)
            for port in ports:
                self.send_lldp_packet(port)
                hub.sleep(self.LLDP_SEND_GUARD)      # don't burst
            if timeout is not None and ports:
                timeout = 0     # We have already slept
            # LOG.debug('lldp sleep %s', timeout)
            self.draw_graph(1, draw=True)
            self.lldp_event.wait(timeout=timeout)
开发者ID:npsccw,项目名称:SDN-Applications,代码行数:35,代码来源:ControlNode.py


示例2: _port_stats_requester

	def _port_stats_requester(self):                           #Defining a function to send port stat request every 10 seconds 
            while True:
                for dp in self.switchports.keys():
                    switch = self.switches[dp]                         #Getting datapath from dpid
                    msg = parser13.OFPPortDescStatsRequest(switch)
                    switch.send_msg(msg)
                hub.sleep(5)                                      # Sleeping for five seconds
开发者ID:Saminderjit,项目名称:networking-projects,代码行数:7,代码来源:test_controller.py


示例3: _topoThread

 def _topoThread(self):
     linkNode = self.zkConf['root'] + self.zkConf['topo'] + self.ip
     if self.zk.exists(linkNode):
         self.zk.set(linkNode, json.dumps(self.links))
     else:
         self.zk.create(linkNode, json.dumps(self.links))
     hub.sleep(self.interval)
开发者ID:LZUSDN,项目名称:lzusdn02,代码行数:7,代码来源:mc.py


示例4: _monitor

 def _monitor(self):
     while True:
         tm_log = open("./ryu/app/AdaptiveIDS/tmlogs.txt", "w")
         tm_log.close()
         for dp in self.datapaths.values():
             self._request_stats(dp.datapath)
         hub.sleep(IDSCfgParams.FLOW_STATS_INTERVAL)
开发者ID:ramprackash,项目名称:ryu,代码行数:7,代码来源:ids_main.py


示例5: _discover

    def _discover(self):###periodically get topology information

	self.debugfile.write("child processing start"+"\n")
	self.debugfile.flush()
        i = 0
	is_fist_time = True	
        while True:
            self.show_topology()###show topology(topo link,link port,access host)

	    if(is_fist_time and i == 1):###we first get the topology information after the child processing start SLEEP_PERIOD time
		self.get_topology(None)	
		self.set_nodelink()
		is_fist_time = False
	   
            if i == 2:
                self.get_topology(None)	###we reflash the topology data and nodelink per 2*SLEEP_PERIOD

		self.set_nodelink()###set self.nodelink	
                i = 0	  	
	    
            hub.sleep(SLEEP_PERIOD)
            i = i + 1

	self.debugfile.write("child processing over"+"\n")
	self.debugfile.flush()	
开发者ID:zhiqiangguo0727,项目名称:MPLS_Based_SFC_Deployment,代码行数:25,代码来源:network_aware.py


示例6: pause

    def pause(self, seconds=0):
        """Relinquishes hub for given number of seconds.

        In other words is puts to sleep to give other greenthread a chance to
        run.
        """
        hub.sleep(seconds)
开发者ID:Huangmachi,项目名称:ryu,代码行数:7,代码来源:base.py


示例7: transact_block

def transact_block(request, connection):
    """Emulate jsonrpc.Connection.transact_block without blocking eventlet.
    """
    error = connection.send(request)
    reply = None

    if error:
        return error, reply

    ovs_poller = poller.Poller()
    while not error:
        ovs_poller.immediate_wake()
        error, reply = connection.recv()

        if error != errno.EAGAIN:
            break

        if (reply and
            reply.id == request.id and
            reply.type in (jsonrpc.Message.T_REPLY,
                           jsonrpc.Message.T_ERROR)):
            break

        connection.run()
        connection.wait(ovs_poller)
        connection.recv_wait(ovs_poller)
        ovs_poller.block()

        hub.sleep(0)

    return error, reply
开发者ID:Aries-Sushi,项目名称:ryu,代码行数:31,代码来源:client.py


示例8: barrier_reply_handler

 def barrier_reply_handler(cls, msg):
     datapath = msg.datapath
     if cls._SENDER != None and\
         datapath.id == cls._SENDER.get_dpid():
         while not isinstance(cls._WAITER, hub.Event):
             hub.sleep(1)
         cls._WAITER.set()
开发者ID:linuxxunil,项目名称:ys-ryu,代码行数:7,代码来源:ys_rest_utils.py


示例9: send_mldquey_regularly

    def send_mldquey_regularly(self):
        self.logger.debug("")
        mc_service_info_list = []
        for line in open(self.MULTICAST_SERVICE_INFO, "r"):
            if line[0] == "#":
                continue
            else:
                # multicast_addr, srcip_addr
                column = list(line[:-1].split(","))
                mc_service_info_list.append(column)
        self.logger.debug(
            "send address(multicast_addr, srcip_addr) : %s",
            str(mc_service_info_list))

        while True:
            for mc_service_info in mc_service_info_list:
                ip_addr_list = []
                if not mc_service_info[1] == "":
                    ip_addr_list.append(mc_service_info[1])
                mld = self.create_mldquery(
                    mc_service_info[0], ip_addr_list)
                sendpkt = self.create_packet(
                    self.addressinfo[0], self.addressinfo[1],
                    self.addressinfo[2], self.addressinfo[3], mld)
                self.send_packet_to_sw(sendpkt)
                hub.sleep(self.WAIT_TIME)
开发者ID:t-koshiba,项目名称:trial,代码行数:26,代码来源:mld_process.py


示例10: _transmit_tc_bpdu

    def _transmit_tc_bpdu(self):
        """ Set send_tc_flg to send Topology Change BPDU. """
        timer = self.port_times.max_age + self.port_times.forward_delay

        self.send_tc_flg = True
        hub.sleep(timer)
        self.send_tc_flg = False
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:7,代码来源:stplib.py


示例11: network_monitor

    def network_monitor(self):
        ''' Monitors network RTT and Congestion '''

        self.logger.info('Starting monitoring sub-routine')
        # First, we get an estimation of the link benchmark_network_capacity
        # in a state where the network will be idle.
        self.benchmark_network_capacity()

        # Then we start the periodic measurement of RTT times and port
        # utilization

        counter = 0
        while True:
            if not self.topo_shape.is_empty():
                self.logger.info('Requesting port stats to '
                                 'measure utilization')
                for dpid, s in self.topo_shape.dpid_to_switch.iteritems():

                    s.port_stats_request_time = time.time()

                    # Requesting portstats to calculate controller
                    # to switch delay and congeston
                    self._request_port_stats(s)

                    # Calculating peering switches RTT (once every 10 portstats
                    # so ~10 secs)
                    if counter % 10 == 0:
                        self.send_latency_probe_packet(s)
                counter += 1

            hub.sleep(1)
开发者ID:dariobanfi,项目名称:multipath-sdn-controller,代码行数:31,代码来源:mpsdn_controller.py


示例12: _monitor

 def _monitor(self):
     while True:
         # Send the states requests to the state tables
         for dp in self.datapaths.values():
             self._request_stats(dp)
         hub.sleep(timewindow)  # Wait X seconds
         self.replies = 0
开发者ID:beba-eu,项目名称:beba-ctrl,代码行数:7,代码来源:simple_monitoring_1.py


示例13: _send_packet_thread

    def _send_packet_thread(self, arg):
        """ Send several packets continuously. """
        if self.ingress_event is None or self.ingress_event._cond:
            return

        # display dots to express progress of sending packets
        if not arg['thread_counter'] % arg['dot_span']:
            sys.stdout.write(".")
            sys.stdout.flush()

        arg['thread_counter'] += 1

        # pile up float values and
        # use integer portion as the number of packets this thread sends
        arg['packet_counter'] += arg['packet_counter_inc']
        count = int(arg['packet_counter'])
        arg['packet_counter'] -= count

        hub.sleep(CONTINUOUS_THREAD_INTVL)

        tid = hub.spawn(self._send_packet_thread, arg)
        self.ingress_threads.append(tid)
        hub.sleep(0)
        for _ in range(count):
            try:
                self.tester_sw.send_packet_out(arg['pkt_data'])
            except Exception as err:
                self.thread_msg = err
                self.ingress_event.set()
                break
开发者ID:paisa4ever,项目名称:ryu,代码行数:30,代码来源:tester.py


示例14: _balance_loop

 def _balance_loop(self):
      while 1:
          self.logger.debug("Balancing")
          #--- tell the system to rebalance
          self.api.run_balancers()
          #--- sleep
          hub.sleep(self.balanceInterval)
开发者ID:jonstout,项目名称:SciPass,代码行数:7,代码来源:Ryu.py


示例15: _update

    def _update(self):
        
        while True:
            for dp in self.datapaths.values():
                parser = dp.ofproto_parser
                ofproto = dp.ofproto
                self.logger.info("dpid="+str(dp.id));
                if dp.id == 161 :
                    
                    self.logger.info("Check SQL Database")
                    db = database()
                    list = db.db_getList()
                    for data in list:
                        print data["id"],"(",type(data["id"]),")"," ",data["address"],"(",type(data["address"]),")"," ",data["access"],"(",type(data["access"]),")"
                        if data["access"] == 1:
                             
                            self.logger.info("DENY "+str(data["address"]))
                            match = parser.OFPMatch(eth_type=0x0800, ipv4_src=str(data["address"]))
                            actions = {}
                            self.add_flow(dp, data["id"]+10, match, actions)

                        if data["access"] == 0:
                            self.logger.info("ALLOW "+str(data["address"]))
                            match = parser.OFPMatch(eth_type=0x0800, ipv4_src=str(data["address"]))
                            mod = parser.OFPFlowMod(dp, command=ofproto.OFPFC_DELETE, out_port=ofproto.OFPP_ANY, out_group=ofproto.OFPG_ANY, match=match)
                            dp.send_msg(mod)



            hub.sleep(10)
开发者ID:SAM33,项目名称:2016-SDN-based-Netcut,代码行数:30,代码来源:main.py


示例16: _send_echo_request

 def _send_echo_request(self):
     for datapath in self.datapaths.values():
         parser = datapath.ofproto_parser
         echo_req = parser.OFPEchoRequest(datapath,
                                          data="%.12f" % time.time())
         datapath.send_msg(echo_req)
         hub.sleep(random.randint(0,10))
开发者ID:onlysheep5200,项目名称:Graduate,代码行数:7,代码来源:delay_detector.py


示例17: _measurement

 def _measurement(self):
     while True:
         print 'ActiveFlows: ', self.active_flows
         print 'FlowRate: ', self.flow_rate
         print 'Graph: ', json.dumps(json_graph.node_link_data(self.graph))
         self._send_measure_request()
         hub.sleep(1)
开发者ID:BenjaminUJun,项目名称:SDNDynamicRouting,代码行数:7,代码来源:ai_switch.py


示例18: _change_status

    def _change_status(self, new_state, thread_switch=True):
        if new_state is not PORT_STATE_DISABLE:
            self.ofctl.set_port_status(self.ofport, new_state)

        if(new_state is PORT_STATE_FORWARD or
                (self.state is PORT_STATE_FORWARD and
                    (new_state is PORT_STATE_DISABLE or
                     new_state is PORT_STATE_BLOCK))):
            self.topology_change_notify(new_state)

        if (new_state is PORT_STATE_DISABLE
                or new_state is PORT_STATE_BLOCK):
            self.send_tc_flg = False
            self.send_tc_timer = None
            self.send_tcn_flg = False
            self.send_bpdu_thread.stop()
        elif new_state is PORT_STATE_LISTEN:
            self.send_bpdu_thread.start()

        self.state = new_state
        self.send_event(EventPortStateChange(self.dp, self))

        if self.state_event is not None:
            self.state_event.set()
            self.state_event = None
        if thread_switch:
            hub.sleep(0)  # For thread switching.
开发者ID:Aries-Sushi,项目名称:ryu,代码行数:27,代码来源:stplib.py


示例19: _routing

    def _routing(self):
        print('system is ready')
        while True:
            if Config.forwarding == 'IP':
                Collector.path = DFS.findAllPairsPath(Collector.topo)
                hub.sleep(5)

            elif Config.forwarding == 'MPLS':
                # localtime = time.asctime(time.localtime(time.time()))
                # print(localtime, 'find Paths is started')
                # start = time.time()
                # create topo
                topo = {}
                for src in Collector.topo:
                    topo[src] = {}
                    for dst in Collector.topo[src]:
                        topo[src][dst] = Collector.topo[src][dst].get_cost()

                Collector.path = AllPairsSP.main(topo)

                path = Collector.path
                datapaths = Collector.datapaths
                topo = Collector.topo
                route = Config.route
                MPLSSetup.main(path, datapaths, topo, route)
                # done = time.time()
                # print('routing calc: ', done - start)
                hub.sleep(60)
开发者ID:haidlir,项目名称:SNHx,代码行数:28,代码来源:main.py


示例20: _update_wait_bpdu_timer

 def _update_wait_bpdu_timer(self):
     if self.wait_timer_event is not None:
         self.wait_timer_event.set()
         self.wait_timer_event = None
         self.logger.debug('[port=%d] Wait BPDU timer is updated.',
                           self.ofport.port_no, extra=self.dpid_str)
     hub.sleep(0)  # For thread switching.
开发者ID:Aries-Sushi,项目名称:ryu,代码行数:7,代码来源:stplib.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python hub.spawn函数代码示例发布时间:2022-05-27
下一篇:
Python hub.kill函数代码示例发布时间: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