Closed brunorijsman closed 3 years ago
I assume that you generated two versions of the same messages or there are two ways of importing them. It is tricky to call protoc
correctly. It is also easy to mess with the PYTHONPATH
.
Take a look at the imports in the key_store_grpc.py
file. Are they look the same as in your program?
import generated.protobuf.key_store_pb2
Tip: it is not necessary to define your own specific Status message, you can use rich error details. You can also map gRPC errors to the corresponding HTTP statuses: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
Thank you. That was indeed the problem. I had "import generated.protobuf.foo_pb2" in my code, where as the generated foo_grpc.py code had "import foo_pb2". I used a "sys.path.append" to be able to consistently use "import foo_pb2" everywhere. This involved some rather ugly hacks to make Visual Studio Code look in the right directories, but I got it to work.
Thanks also for the other tips.
I will close the issue.
Closing (see above)
I am running into a strange error message when using the
ChannelFor
andStub
functionality in a pytest.grpclib.encoding.proto.ProtoCodec.encode
throws the following exception:Note that the expected type and the actual type are the same, namely
<class 'key_store_pb2.AddBlockRequest'>
Program:
Proto file:
Invoking the program:
Full error message: