Python: server-side abort() always throws exception on calling client-side?

768 views
Skip to first unread message

Jens Troeger

unread,
Dec 28, 2022, 9:08:55 AM12/28/22
to grpc.io
Hello, suppose I create a request

request = SomeRequest(name="Name", data=data)

and send that off to the gRPC server:

response = some_stub.DoStuff(request)

then all works fine for grpc.Status.OK. However, it seems that any error response status causes an exception on the calling client, e.g.

E   grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
E     status = StatusCode.INVALID_ARGUMENT
E     details = "..."
E     debug_error_string = "..."
E   >


Is that exception intended, i.e. does any error response always result in an exception here?

I’m also a little befuddled by the “inactive” and I wonder if I’m missing something, or if this just odd naming?

Much thanks!
Jens

sanjay...@google.com

unread,
Dec 28, 2022, 1:17:55 PM12/28/22
to grpc.io
Check this out https://grpc.github.io/grpc/python/grpc.html#grpc-exceptions 

"Raised by the gRPC library to indicate non-OK-status RPC termination." (although it doesn't reference InactiveRpcError there for which I don't have an answer)

Exception is the only way to indicate an error in the RPC since returning error via the return value is not possible.

Jens Troeger

unread,
Dec 29, 2022, 3:22:13 AM12/29/22
to grpc.io
Thank you!

Looking at the code for _InactiveRpcError it does indeed inherit from RpcError. Unfortunately though, that base class doesn’t give any hint regarding the actual failure which, I suspect, is why subclasses and their status codes exist. Declaring code() (and other useful helpers) as an abstract method on RpcError would be helpful 🤔

Sanjay Pujare

unread,
Dec 29, 2022, 12:45:53 PM12/29/22
to Jens Troeger, grpc.io
If you feel strongly about this, you can open an issue on https://github.com/grpc/grpc for Python. 

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/84889b3a-945a-4163-b08c-2218e2a7f069n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages