我是python async GRPC的新手,我提出了以下方法来处理异步流:
async with grpc.aio.insecure_channel(target='localhost:6565', options=CHANNEL_OPTIONS) as channel:
stub = get_results_grpc.ResultServiceStub(channel)
stream = stub.GetResults(get_results_pb2.PositionsRequest(name=["test"]), timeout=10, metadata=metadata)
try:
async for resp in stream.__aiter__():
print(resp)
except grpc.RpcError as e:
print(e)
await asyncio.sleep(10)
stream.cancel()
然而,一旦蒸汽中没有结果,则循环将结束,然后蒸汽将关闭,程序退出。我怎样才能保持溪流畅通
在Java中,我可以使用倒计时闩锁来保持异步grpc流打开
目前没有回答
相关问题 更多 >
编程相关推荐