如何在 thrift python 客户端中设置 rpc 超时? [英] How to set rpc timeout in thrift python client?

查看:93
本文介绍了如何在 thrift python 客户端中设置 rpc 超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我的客户端代码如下:

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

推荐答案

您可以使用 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)

这篇关于如何在 thrift python 客户端中设置 rpc 超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆