长时间调用的节俭超时:thrift.transport.TTransport.TTransportException:TSocket 读取 0 字节 [英] thrift timeout for long run call: thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

查看:59
本文介绍了长时间调用的节俭超时:thrift.transport.TTransport.TTransportException:TSocket 读取 0 字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 thrift 构建了一些 rpc 服务.每次调用可能会运行很长时间(几分钟到几小时).我已将 thrift 超时设置为 2 天.

I've build some a rpc service using thrift. It may run long time (minutes to hours) for each call. I've set the thrift timeout to 2 days.

transport = TSocket.TSocket(self.__host, self.__port)
transport.setTimeout(2 * 24 * 60 * 60 * 1000)

但是 thrift 总是在大约 600 秒后关闭连接,以下情况除外:

But the thrift always closes connection after about 600s, with the following exception:

thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

我还应该设置其他超时吗?(python,thrift 服务器:windows;客户端:ubuntu)

Is there's any other timeout should i set? (python, thrift server: windows; client: ubuntu)

推荐答案

Thrift Transport 连接正在断开.这可能是由于网络问题或远程服务重启或超时问题.无论何时在断开连接后进行任何调用都会导致 TTransportException.这个问题可以通过重新连接远程服务来解决.尝试使用它,在进行远程服务调用之前调用它.

The Thrift Transport connection is being disconnected. This could be due to network issues or remote service restart or time out issues. Whenever any call is made after a disconnect this results in TTransportException. This problem can be solved by reconnecting to the remote service. Try using this, invoking it before making a remote service call.

def repoen_transport():
    try:
        if not transport.isOpen():
            transport.open()
    except Exception, msg:
        print >> sys.stderr.write("Error reopening transport {}".format(msg))

这篇关于长时间调用的节俭超时:thrift.transport.TTransport.TTransportException:TSocket 读取 0 字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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