def _adv_poller(self): # give the system a few seconds to start the first time so that any expressions # due to nearby units will be rendered properly time.sleep(20) while True: try: logging.debug("polling pwngrid-peer for peers ...") grid_peers = grid.peers() new_peers = {} self._closest_peer = None for obj in grid_peers: peer = Peer(obj) new_peers[peer.identity()] = peer if self._closest_peer is None: self._closest_peer = peer # check who's gone to_delete = [] for ident, peer in self._peers.items(): if ident not in new_peers: to_delete.append(ident) for ident in to_delete: self._on_lost_peer(self._peers[ident]) del self._peers[ident] for ident, peer in new_peers.items(): # check who's new if ident not in self._peers: self._peers[ident] = peer self._on_new_peer(peer) # update the rest else: self._peers[ident].update(peer) except Exception as e: logging.warning("error while polling pwngrid-peer: %s" % e) logging.debug(e, exc_info=True) time.sleep(3)
def _adv_poller(self): while True: logging.debug("polling pwngrid-peer for peers ...") try: grid_peers = grid.peers() new_peers = {} self._closest_peer = None for obj in grid_peers: peer = Peer(obj) new_peers[peer.identity()] = peer if self._closest_peer is None: self._closest_peer = peer # check who's gone to_delete = [] for ident, peer in self._peers.items(): if ident not in new_peers: self._view.on_lost_peer(peer) plugins.on('peer_lost', self, peer) to_delete.append(ident) for ident in to_delete: del self._peers[ident] for ident, peer in new_peers.items(): # check who's new if ident not in self._peers: self._peers[ident] = peer self._view.on_new_peer(peer) plugins.on('peer_detected', self, peer) # update the rest else: self._peers[ident].update(peer) except Exception as e: logging.exception("error while polling pwngrid-peer") time.sleep(1)
def _adv_poller(self): while True: try: logging.debug("polling pwngrid-peer for peers ...") grid_peers = grid.peers() new_peers = {} self._closest_peer = None for obj in grid_peers: peer = Peer(obj) new_peers[peer.identity()] = peer if self._closest_peer is None: self._closest_peer = peer # check who's gone to_delete = [] for ident, peer in self._peers.items(): if ident not in new_peers: to_delete.append(ident) for ident in to_delete: self._on_lost_peer(self._peers[ident]) del self._peers[ident] for ident, peer in new_peers.items(): # check who's new if ident not in self._peers: self._peers[ident] = peer self._on_new_peer(peer) # update the rest else: self._peers[ident].update(peer) except Exception as e: logging.warning("error while polling pwngrid-peer: %s" % e) logging.debug(e, exc_info=True) time.sleep(3)