Python: setting service wide client timeout

35 views
Skip to first unread message

Amit Saha

unread,
Sep 2, 2017, 4:24:20 AM9/2/17
to grpc.io
Hi all,

I can set call specific timeout as follows:

response = stub.CreateUser(
            users_messages.CreateUserRequest(username='tom'),
            metadata=metadata,
            timeout=30,
 )

Is it possible to set timeout when creating the stub (so that i don't have to set the timeout per call)? I could create a wrapper to do this automatically, something like this i guess:

def wrapped_client(stub, method, data, metadata):
    # not sure if this actually works..more of an idea
    getattr(stub, method)(data, metadata=metadata,timeout=30)

and then always use this wrapper.


Thanks,
Amit.



Evan Jones

unread,
Sep 5, 2017, 10:10:26 AM9/5/17
to grpc.io
I think this is exactly what Service Configs are supposed to solve, but I haven't investigate them at all: https://github.com/grpc/grpc/blob/master/doc/service_config.md

Hope that helps,

Evan

Nathaniel Manista

unread,
Sep 13, 2017, 12:22:20 AM9/13/17
to Amit Saha, grpc.io
This is not possible today with gRPC Python. It's likely coming in the future, either with interceptors support or some other mechanism.
-Nathaniel

Amit Saha

unread,
Sep 14, 2017, 4:34:53 AM9/14/17
to Nathaniel Manista, grpc.io
Thanks. 
Reply all
Reply to author
Forward
0 new messages