用于调用函数并执行.同时如果执行出错也负责将错误转化为对应的调用错误返回给客户端.

        执行成功后根据结果进行不同的处理,如果注册的是函数,实例中的方法,或者协程,则获取计算得的结果,并返回给客户端.
        如果是异步生成器函数,那么返回的就是一个对应的异步生成器,我们通过对其包装后循环调用实现流传输.

        Parameters:
            request (Dict[str, Any]): - python字典形式的请求

        Raise:
            (Exception): - 当执行调用后抛出了异常,且异常不在定义范围内,则抛出

        Return:
            (bool): - 当正常调用则返回True,如果抛出了规定范围内的异常则返回False

async def _RPC_handler(self, request: Dict[str, Any]):
        """用于调用函数并执行.同时如果执行出错也负责将错误转化为对应的调用错误返回给客户端.

        执行成功后根据结果进行不同的处理,如果注册的是函数,实例中的方法,或者协程,则获取计算得的结果,并返回给客户端.
        如果是异步生成器函数,那么返回的就是一个对应的异步生成器,我们通过对其包装后循环调用实现流传输.

        Parameters:
            request (Dict[str, Any]): - python字典形式的请求

        Raise:
            (Exception): - 当执行调用后抛出了异常,且异常不在定义范围内,则抛出

        Return:
            (bool): - 当正常调用则返回True,如果抛出了规定范围内的异常则返回False

        """
        ID = request.get("ID")
        method = request.get("METHOD")
        with_return = request.get("RETURN")
        args = request.get("ARGS") or []
        kwargs = request.get("KWARGS") or {}
        try:
            if method is None:
                raise RequestError(
                    "request do not have method", request.get("ID"))
            if method == "system.getresult":
                await self._get_result(ID, *args, **kwargs)
            else:
                result = await self.method_wrapper.apply(ID, method,
                                                         *args, **kwargs)
        except MethodError as se:
            exinfo = traceback.TracebackException.from_exception(
                se).format(chain=True)
            frames = "".join([i + "/n" for i in exinfo])
            response = {
                "MPRPC": self.VERSION,
                "CODE": se.status_code,
                "MESSAGE": {
                    "ID": ID,
                    'EXCEPTION': str(type(se)),
                    'MESSAGE': str(se),
                    "DATA": {
                        'METHOD': request.get("METHOD"),
                        "ARGS": request.get("ARGS"),
                        "KWARGS": request.get("KWARGS"),
                        'FRAME': frames}
                }
            }
            self.writer(response)
            return False
        except ServerException as me:
            response = {
                "MPRPC": self.VERSION,
                "CODE": me.status_code,
            }
            self.writer(response)
            return False
        except Exception as e:
            if self.debug is True:
                raise e
            else:
                logger.info(
                    "Task[{}]: Unknown Error {}:\nmessage:{}".format(
                        ID, e.__class__.__name__, str(e))
                )
        else:
            if with_return:
                if inspect.isasyncgen(result):
                    await self._asyncgen_wrap(result, ID)
                else:
                    response = {
                        "MPRPC": self.VERSION,
                        "CODE": 200,
                        "MESSAGE": {
                            "ID": ID,
                            'RESULT': result
                        }
                    }
                    self.writer(response)
                    if self.debug:
                        access_logger.info(
                            "Task[{}]: response answered".format(ID),
                            extra=self._extra
                        )
            return result