user469635
user469635

Reputation: 59

python grpc: setting timeout per grpc call

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.

Upvotes: 3

Views: 3052

Answers (1)

Lidi Zheng
Lidi Zheng

Reputation: 2091

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

Upvotes: 3

Related Questions