service ABC {
rpc DataTransmission (stream DataTransmissionRequest) returns (stream DataTransmissionResponse);
message DataTransmissionRequest {
bytes data = 1;
string ticket = 2;
message DataTransmissionResponse {
bytes data = 1;
}
下面是我的客户端代码,用于生成迭代器请求并调用dataTransmission函数
代码语言:
javascript
复制
def generateRequests():
req_msgs = [
(b"123", "sySJZDV9Rb8dyqt1"),
(b"123"),
(b"123"),
(b"123"),
(b"123"),
(b"123"),
iter = 0
for (req, ticket) in req_msgs:
print("(req, ticket) = ", (req, ticket))
if iter == 0:
request = ABC_pb2.DataTransmissionRequest(data=req, ticket=ticket)
else:
request = ABC_pb2.DataTransmissionRequest(data=req)
iter += 1
print("iter = ", iter)
yield request
#my_queue = queue.SimpleQueue()
with grpc.insecure_channel(addr) as channel:
stub = ABC_pb2_grpc.ServiceProxyStub(channel)
data_transmission_resp = stub.DataTransmission(generateRequests())
print("data_transmission_resp = ", data_transmission_resp)
##print("data_transmission_resp = ", list(data_transmission_resp))
## use the results
for data_trans in data_transmission_resp:
print(data_trans)
但得到了错误
代码语言:
javascript
复制
grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
status = StatusCode.UNKNOWN
details = "Exception iterating requests!"