0
I’m testing some code using gRPC with the Python language, and I’m not able to manipulate array. The code consists of passing an array per parameter, the server receives this array and sorts.
code . proto
syntax = "proto3";
message Number {
repeated int32 value = 1;
}
Code sorts.py
def organiza(vetor):
vetor.sort()
return vetor
server.py
class OrdenaServicer(ordena_pb2_grpc.OrdenaServicer):
def Organiza(self, request, context):
response = ordena_pb2.Number()
response.value = int(ordena.organiza(request.value))
return response
service Ordena {
rpc Organiza(Number) returns (Number) {}
}
client py.
# create a stub (client)
stub = ordena_pb2_grpc.OrdenaStub(channel)
# create a valid request message
vetor = [23,65,8,3,89,34,6,22,12,5,9,54]
number = ordena_pb2.Number(value=vetor)
# make the call
response = stub.Organiza(number)
The code itself is very simple, consists only of a basic ordering, but I am not able to pass the vector as parameter. Every time I try to make a mistake:
Typeerror: int() argument must be a string, a bytes-like Object or a number, not 'google.protobuf.pyext. _message.Repeatedscalarcontainer'
Thanks! It worked right here.
– Juny