Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set rpc timeout in thrift python client?

Tags:

python

rpc

thrift

I'm writing python client using thrift, but I can't find any available option to set rpc time out.

My client code goes below:

socket = TSocket.TSocket(address, port)
transport = TTransport.TBufferedTransport(socket)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
server = Client.Client(protocol)
transport.open()
like image 905
shuxiong Avatar asked Aug 20 '12 08:08

shuxiong


1 Answers

You can use socket.setTimeout() method.

from thrift.transport.THttpClient import THttpClient
socket = THttpClient(server_url)
socket.setTimeout(SERVICE_TIMEOUT_IN_mS)
transport = TTransport.TBufferedTransport(socket)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
like image 121
srj Avatar answered Oct 30 '22 08:10

srj