Ciao Sto cercando di scrivere un semplice server di risparmio in python (denominato PythonServer.py) con un singolo metodo che restituisce una stringa per scopi di apprendimento. Il codice del server è sotto. Sto avendo i seguenti errori nelle librerie Python di Thrift quando eseguo il server. Qualcuno ha riscontrato questo problema e suggerisce una soluzione alternativa?Problema: TypeError: getaddrinfo() argomento 1 deve essere stringa o None
L'output esecuzione:
Starting server
Traceback (most recent call last):
File "/home/dae/workspace/BasicTestEnvironmentV1.0/src/PythonServer.py", line 38, in <module>
server.serve()
File "usr/lib/python2.6/site-packages/thrift/server/TServer.py", line 101, in serve
File "usr/lib/python2.6/site-packages/thrift/transport/TSocket.py", line 136, in listen
File "usr/lib/python2.6/site-packages/thrift/transport/TSocket.py", line 31, in _resolveAddr
TypeError: getaddrinfo() argument 1 must be string or None
PythonServer.java
port = 9090
import MyService as myserv
#from ttypes import *
# Thrift files
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer
# Server implementation
class MyHandler:
# return server message
def sendMessage(self, text):
print text
return 'In the garage!!!'
# set handler to our implementation
handler = MyHandler()
processor = myserv.Processor(handler)
transport = TSocket.TServerSocket(port)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()
# set server
server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
print 'Starting server'
server.serve() ##### LINE 38 GOES HERE ##########
Sì, effettivamente questo ha aiutato. Molte grazie. – farda
Prego. –
@farda Si prega di premiare le risposte corrette facendo clic sulla casella di controllo. – wberry