How to set rpc timeout in thrift python client?

有些话、适合烂在心里 提交于 2019-12-07 04:59:01

问题


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()

回答1:


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)


来源:https://stackoverflow.com/questions/12034768/how-to-set-rpc-timeout-in-thrift-python-client

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