1. 程式人生 > >thrift TypeError: getaddrinfo() argument 1 must be string or None

thrift TypeError: getaddrinfo() argument 1 must be string or None

2012-05-31

thrift tutorial中執行python的PythonServer.py,遇到如下錯誤:

[[email protected] py]$ python PythonServer.py
Starting the server...
Traceback (most recent call last):
  File "PythonServer.py", line 95, in <module>
    server.serve()
  File "build/bdist.linux-x86_64/egg/thrift/server/TServer.py", line 74, in serve
  File "build/bdist.linux-x86_64/egg/thrift/transport/TSocket.py", line 136, in listen
  File "build/bdist.linux-x86_64/egg/thrift/transport/TSocket.py", line 31, in _resolveAddr
TypeError: getaddrinfo() argument 1 must be string or None

我們看一下File “PythonServer.py”, line 95,是這句

transport = TSocket.TServerSocket(9090)

我們看TserverSocket原始碼,[[email protected] py]# vim build/lib.linux-x86_64-2.7/thrift/transport/TSocket.py

def __init__(self, host=None, port=9090, unix_socket=None):

這是因為其初始化函式,第一個引數是host,第二個引數是port,所以想省去host,只填port是不行的。

將File “PythonServer.py”, line 95改為:

transport = TSocket.TServerSocket('localhost',9090)

或者改為:

transport = TSocket.TServerSocket(port=9090)

即可解決該問題。

如非註明轉載, 均為原創. 本站遵循知識共享CC協議,轉載請註明來源