def METHOD_NAME(self):
    request = udf_pb2.Request()
    while True:
        msg = 'unknown'
        try:
            size = decodeUvarint32(self._in)
            data = self._in.read(size)
            request.ParseFromString(data)
            # use parsed message
            msg = request.WhichOneof("message")
            if msg == "info":
                response = self.handler.info()
                self.write_response(response, flush=True)
            elif msg == "init":
                response = self.handler.init(request.init)
                self.write_response(response, flush=True)
            elif msg == "keepalive":
                response = udf_pb2.Response()
                response.keepalive.time = request.keepalive.time
                self.write_response(response, flush=True)
            elif msg == "snapshot":
                response = self.handler.snapshot()
                self.write_response(response, flush=True)
            elif msg == "restore":
                response = self.handler.restore(request.restore)
                self.write_response(response, flush=True)
            elif msg == "begin":
                self.handler.begin_batch(request.begin)
            elif msg == "point":
                self.handler.point(request.point)
            elif msg == "end":
                self.handler.end_batch(request.end)
            else:
                logger.error("received unhandled request %s", msg)
        except EOF:
            break
        except Exception as e:
            traceback.print_exc()
            error = "error processing request of type %s: %s" % (msg, e)
            logger.error(error)
            response = udf_pb2.Response()
            response.error.error = error
            self.write_response(response)
            break