def _link_request_sync(self, interval): while self.is_active: request = event.EventLinkRequest() LOG.debug('link_request sync %s thread(%s)', request, id(hub.getcurrent())) reply = self.send_request(request) LOG.debug('link_reply sync %s', reply) if len(reply.links) > 0: for link in reply.links: LOG.debug(' %s', link) hub.sleep(interval)
def _link_request_async(self, interval): while self.is_active: request = event.EventLinkRequest() LOG.debug('link_request async %s thread(%s)', request, id(hub.getcurrent())) self.send_event(request.dst, request) start = time.time() busy = interval / 2 i = 0 while i < busy: if time.time() > start + i: i += 1 LOG.debug(' thread is busy... %s/%s thread(%s)', i, busy, id(hub.getcurrent())) LOG.debug(' thread yield to link_reply handler. thread(%s)', id(hub.getcurrent())) # yield hub.sleep(0) LOG.debug(' thread get back. thread(%s)', id(hub.getcurrent())) hub.sleep(interval - busy)
def get_link(app, dpid=None): rep = app.send_request(event.EventLinkRequest(dpid)) return rep.links
def get_links(self): rep = self.send_request(event.EventLinkRequest(None)) return rep.links
def get_link(app): rep = app.send_request(event.EventLinkRequest(None)) return rep.links