def unix_connect(path, service=VoidService, config={}): """ creates a socket-connection to the given unix domain socket :param path: the path to the unix domain socket :param service: the local service to expose (defaults to Void) :param config: configuration dict :returns: an RPyC connection """ s = SocketStream.unix_connect(path) return connect_stream(s, service, config)
def unix_connect(socket_path, retry=10) -> rpyc.Connection: """ Connects to bridge using unix socket. """ for i in range(retry): try: logger.debug(f"Connecting to socket path: {socket_path}, try {i + 1}") stream = SocketStream.unix_connect(socket_path) link = rpyc.classic.connect_stream(stream) link.ping() logger.debug(f"Connected to {socket_path}") return link except socket.error: time.sleep(1) continue raise DragodisError(f"Could not connect to {socket_path} after {retry} tries.")