(service_name, host = None, registrar = None, timeout = 2)
return addrs
discovers hosts running the given service
    
    :param service_name: the service to look for
    :param host: limit the discovery to the given host only (None means any host)
    :param registrar: use this registry client to discover services. if None,
                      use the default UDPRegistryClient with the default settings.
    :param timeout: the number of seconds to wait for a reply from the registry
                    if no hosts are found, raises DiscoveryError
    
    :raises: ``DiscoveryError`` if no server is found
    :returns: a list of (ip, port) pairs
discovers hosts running the given service
    
    :param service_name: the service to look for
    :param host: limit the discovery to the given host only (None means any host)
    :param registrar: use this registry client to discover services. if None,
                      use the default UDPRegistryClient with the default settings.
    :param timeout: the number of seconds to wait for a reply from the registry
                    if no hosts are found, raises DiscoveryError
    
    :raises: ``DiscoveryError`` if no server is found
    :returns: a list of (ip, port) pairs
discovers hosts running the given service : param service_name : the service to look for : param host : limit the discovery to the given host only ( None means any host ) : param registrar : use this registry client to discover services . if None use the default UDPRegistryClient with the default settings . : param timeout : the number of seconds to wait for a reply from the registry if no hosts are found raises DiscoveryError : raises : DiscoveryError if no server is found : returns : a list of ( ip port ) pairs
def discover(service_name, host = None, registrar = None, timeout = 2):
    """
    discovers hosts running the given service
    
    :param service_name: the service to look for
    :param host: limit the discovery to the given host only (None means any host)
    :param registrar: use this registry client to discover services. if None,
                      use the default UDPRegistryClient with the default settings.
    :param timeout: the number of seconds to wait for a reply from the registry
                    if no hosts are found, raises DiscoveryError
    
    :raises: ``DiscoveryError`` if no server is found
    :returns: a list of (ip, port) pairs
    """
    if registrar is None:
        registrar = UDPRegistryClient(timeout = timeout)
    addrs = registrar.discover(service_name)
    if not addrs:
        raise DiscoveryError("no servers exposing %r were found" % (service_name,))
    if host:
        ips = socket.gethostbyname_ex(host)[2]
        addrs = [(h, p) for h, p in addrs if h in ips]
    if not addrs:
        raise DiscoveryError("no servers exposing %r were found on %r" % (service_name, host))
    return addrs
def discover ( service_name , host = None , registrar = None , timeout = 2 ) : if registrar is None : registrar = UDPRegistryClient ( timeout = timeout ) addrs = registrar . discover ( service_name ) if not addrs : raise DiscoveryError ( "no servers exposing %r were found" % ( service_name , ) ) if host : ips = socket . gethostbyname_ex ( host ) [ 2 ] addrs = [ ( h , p ) for h , p in addrs if h in ips ] if not addrs : raise DiscoveryError ( "no servers exposing %r were found on %r" % ( service_name , host ) ) return addrs