Hi, we've been using grpcext.intercept_server() UnaryServerInterceptor and inspecting the server's return code like this:
def intercept_unary(self, request, servicer_context, server_info, handler):
try:
handler(request, servicer_context)
except:
code = servicer_context._state.code
...
We know this is not great: technically _state is private, but the ServicerContext offers no other public API for getting the code out of it.
The problem comes when we ALSO try to use open_tracing_server_interceptor(). When we do that, the servicer_context is replaced with an _OpenTracingServicerContext. And _OpenTracingServicerContext does not expose _state, so the above code breaks.
Yes, we know it's our fault for relying on the private _state field. But would it be possible to request a way to read the code/details from within a UnaryServerInterceptor, that would work whether or not we're using open_tracing_server_interceptor()?
Hi, we've been using
grpcext.intercept_server()UnaryServerInterceptorand inspecting the server's returncodelike this:We know this is not great: technically
_stateis private, but theServicerContextoffers no other public API for getting thecodeout of it.The problem comes when we ALSO try to use
open_tracing_server_interceptor(). When we do that, theservicer_contextis replaced with an_OpenTracingServicerContext. And_OpenTracingServicerContextdoes not expose_state, so the above code breaks.Yes, we know it's our fault for relying on the private
_statefield. But would it be possible to request a way to read thecode/detailsfrom within aUnaryServerInterceptor, that would work whether or not we're usingopen_tracing_server_interceptor()?