Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python grpc: setting timeout per grpc call

Tags:

grpc-python

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.

like image 989
user469635 Avatar asked Apr 02 '26 16:04

user469635


1 Answers

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
like image 118
Lidi Zheng Avatar answered Apr 04 '26 06:04

Lidi Zheng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!