Closed CaueP closed 1 year ago
While debugging the method call (return method(request, context)
) in the try
block, I noticed that the exception is being returned instead of raised, that's why the exception isn't being captured. I will check if this is the default behavior.
Hi @CaueP,
First off, thanks for the detailed report. The issue here is that method
in the interceptor is a "continuation" as described in the client interceptor section of the gRPC docs. When you invoke the continuation, you actually get a future back, which resolves to either the result, or exception. I acknowledge this is confusing because it's a different API than the stub, but that's how the Python gRPC package is implemented.
Luckily it's not hard to do what you want. Check out this test as an example. I think the docs could be improved to describe the continuation better. I can update them when I have more time.
Hey @dan-hipschman-od, thanks a lot for the explanation and the code example! I was able to solve my issue. 😃
Hi there!
I'm creating an interceptor to improve the exception logging on my gRPC client but the interceptor never enters the
except
block when aRpcError
exception is raised. I added logs in thetry
block wheremethod
is called and in theexcept
block and only the first log is run. Is it the expected behavior or am I doing something wrong?The library versions I'm using:
Below is my interceptor implementation, following the example of client interceptors:
My
GrpcClient
:A client call example:
My log output when my gRPC server was down to cause an
UNAVAILABLE
error on client. Note that only the log before the RPC being executed appears and then the exception is thrown: