【发布时间】:2020-09-11 00:27:53
【问题描述】:
我只是想停止/关闭一个用 python 创建的节俭的 TSimpleServer。但是,由于错误“AttributeError: 'TSimpleServer' object has no attribute 'stop'”,没有 .stop() 和 .close() 可以执行此操作。有什么办法可以解决这个问题吗?任何帮助将不胜感激。
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer
from rpc1_nodejs_call_python import printService
from TestHandler import TestHandler
processor = printService.Processor(TestHandler())
transport = TSocket.TServerSocket(host='127.0.0.1', port=8080)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()
server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)
print("Starting thrift server in python...")
server.serve()
print("Stoping thrift server in python...")
server.stop()
# server.close()
【问题讨论】: