python grpc: setting timeout per grpc call

别来无恙 提交于 2021-02-11 14:57:22

问题


Is there a way to specify timeout per grpc call with python. I am experiencing more than 1 minute delay in receiving response. I want the api to return some error in case it is taking longer that specified time. I am using blocking grpc call.


回答1:


You can look up the information you want at gRPC Python's API reference. Setting timeout should be as simple as:

channel = grpc.insecure_channel(...)
stub = ...(channel)
stub.AnRPC(request, timeout=5)  # 5 seconds timeout


来源:https://stackoverflow.com/questions/57920099/python-grpc-setting-timeout-per-grpc-call

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!