与龙卷风示例服务器的thrift引发异常

时间:2016-04-08 10:36:06

标签: python python-2.7 tornado thrift

我正在运行官方节俭py:tornado demo,在客户关闭运输后引发异常。

示例:https://github.com/apache/thrift/tree/master/tutorial/py.tornado

Starting the server...
ping()
add(1, 1)
zip()
zip()
calculate(1, Work(comment=None, num1=1, num2=0, op=4))
calculate(1, Work(comment=None, num1=15, num2=10, op=2))
getStruct(1)
ERROR:thrift.TTornado:thrift exception in handle_stream
Traceback (most recent call last):
  File "/Users/user/venv/py27/lib/python2.7/site-packages/thrift/TTornado.py", line 174, in handle_stream
    frame = yield trans.readFrame()
  File "/Users/user/venv/py27/lib/python2.7/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/Users/user/venv/py27/lib/python2.7/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "/Users/user/venv/py27/lib/python2.7/site-packages/tornado/gen.py", line 1014, in run
    yielded = self.gen.throw(*exc_info)
  File "/Users/user/venv/py27/lib/python2.7/site-packages/thrift/TTornado.py", line 141, in readFrame
    raise gen.Return(frame)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/user/venv/py27/lib/python2.7/site-packages/thrift/TTornado.py", line 125, in io_exception_context
    message=str(e))
TTransportException: Stream is closed

有没有办法避免这个错误消息或如何捕获它?

1 个答案:

答案 0 :(得分:0)

很多原因会导致StreamClosedError

  1. 检查节俭服务器端,可能会引发异常。
  2. 经过测试,我发现节俭THttpServer无法提供Tornado客户端流。
  3. 并且,当我将龙卷风版本从4.4.3升级到4.5时,StreamClosedError消失了。
  4. 客户端Thrift版本:0.10.0

    龙卷风版:4.5

    客户端Python版本:3.5.2

    系统版本:Ubuntu 16.04