def discover(self, service): from rpyc.utils.factory import unix_connect, connect if self.discoverer is None or self.discoverer.closed: try: if self.path: self.discoverer = unix_connect(self.path) else: self.discoverer = connect(self.host, self.port) except: raise DiscoveryError('Discovery service not found.') info = dict(self.discoverer.root.discover(service)) if info is not None: if 'socket_path' in info: return unix_connect(info.get('socket_path')) else: return connect(info.get('hostname'), info.get('port')) else: raise DiscoveryError('Service discovery failed.')
def connect(host, port=DEFAULT_SERVER_PORT, ipv6=False): """ Creates a socket connection to the given host and port. :param host: the host to connect to :param port: the TCP port :param ipv6: whether to create an IPv6 socket or IPv4 :returns: an RPyC connection exposing ``SlaveService`` """ return factory.connect(host, port, SlaveService, ipv6=ipv6)
def connect(host, port = DEFAULT_SERVER_PORT): """creates a socket connection to the given host and port""" return factory.connect(host, port, SlaveService)
def connect(host, port=DEFAULT_SERVER_PORT): """creates a socket connection to the given host and port""" return factory.connect(host, port, SlaveService)