I am testing some codes using gRPC with the Python language, and I am not able to manipulate array. The code consists of passing one vector per parameter, the server receives that vector and sorts.
.proto code
syntax = "proto3";
message Number {
repeated int32 value = 1;
}
Code orders.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, it is only a basic sort, but I can not pass the vector as a parameter. Whenever I try to get an error:
TypeError: int () argument must be a string, a byte-like object or a number, not 'google.protobuf.pyext._message.RepeatedScalarContainer'