gRPC Python 目前不支持服务器端全局错误处理程序。拦截器不会执行内部的服务器处理程序intercept_service
函数,所以没有办法尝试/例外。
另外,我发现 gRPC Python 服务器拦截器实现与他们最初提出的不同L13-Python-Interceptors.md#server-interceptors https://github.com/grpc/proposal/blob/361846400834164d21c12ca6cf60e8cbf501d6cd/L13-Python-Interceptors.md#server-interceptors。如果实现坚持最初的设计,我们可以轻松地使用拦截器作为全局错误处理程序handler
and request
/request_iterator
.
# Current Implementation
intercept_service(self, continuation, handler_call_details)
# Original Design
intercept_unary_unary_handler(self, handler, method, request, servicer_context)
intercept_unary_stream_handler(self, handler, method, request, servicer_context)
intercept_stream_unary_handler(self, handler, method, request_iterator, servicer_context)
intercept_stream_stream_handler(self, handler, method, request_iterator, servicer_context)
请将功能请求问题提交至https://github.com/grpc/grpc/issues https://github.com/grpc/grpc/issues.