(self, host, name)
return tuple(servers)
implementation of the ``query`` command
implementation of the ``query`` command
implementation of the query command
def cmd_query(self, host, name):
        """implementation of the ``query`` command"""
        name = name.upper()
        self.logger.debug("querying for %r", name)
        if name not in self.services:
            self.logger.debug("no such service")
            return ()

        oldest = time.time() - self.pruning_timeout
        all_servers = sorted(self.services[name].items(), key = lambda x: x[1])
        servers = []
        for addrinfo, t in all_servers:
            if t < oldest:
                self.logger.debug("discarding stale %s:%s", *addrinfo)
                self._remove_service(name, addrinfo)
            else:
                servers.append(addrinfo)

        self.logger.debug("replying with %r", servers)
        return tuple(servers)
def cmd_query ( self , host , name ) : name = name . upper ( ) self . logger . debug ( "querying for %r" , name ) if name not in self . services : self . logger . debug ( "no such service" ) return ( ) oldest = time . time ( ) - self . pruning_timeout all_servers = sorted ( self . services [ name ] . items ( ) , key = lambda x : x [ 1 ] ) servers = [ ] for addrinfo , t in all_servers : if t < oldest : self . logger . debug ( "discarding stale %s:%s" , * addrinfo ) self . _remove_service ( name , addrinfo ) else : servers . append ( addrinfo ) self . logger . debug ( "replying with %r" , servers ) return tuple ( servers )