【问题标题】:How to set rpc timeout in thrift python client?如何在 Thrift python 客户端中设置 rpc 超时?
【发布时间】:2012-08-15 14:42:05
【问题描述】:

我正在使用 thrift 编写 python 客户端,但我找不到任何可用的选项来设置 rpc 超时。

我的客户端代码如下:

socket = TSocket.TSocket(address, port)
transport = TTransport.TBufferedTransport(socket)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
server = Client.Client(protocol)
transport.open()

【问题讨论】:

    标签: python rpc thrift


    【解决方案1】:

    你可以使用socket.setTimeout()方法。

    from thrift.transport.THttpClient import THttpClient
    socket = THttpClient(server_url)
    socket.setTimeout(SERVICE_TIMEOUT_IN_mS)
    transport = TTransport.TBufferedTransport(socket)
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-28
    • 2011-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-01
    • 2011-07-24
    相关资源
    最近更新 更多