Python:如何以编程方式停止thrift服务器?
我只想停止/关闭用python创建的thrift TSimpleServer。但是,没有.stop()和.close()可以执行此操作,因为出现了错误“AttributeError:'TSimpleServer'对象没有属性'stop'。是否有任何解决方案可以解决此问题?任何帮助都将不胜感激Python:如何以编程方式停止thrift服务器?,python,server,thrift,Python,Server,Thrift,我只想停止/关闭用python创建的thrift TSimpleServer。但是,没有.stop()和.close()可以执行此操作,因为出现了错误“AttributeError:'TSimpleServer'对象没有属性'stop'。是否有任何解决方案可以解决此问题?任何帮助都将不胜感激 from thrift.transport import TSocket from thrift.transport import TTransport from thrift.protocol impor
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()
实际上,这似乎根本不可能/无法预见: 正如您所注意到的,没有
stop()
,所有三个服务器的实现目前都在无限循环,而true则是
通常的方法是,假设有人要添加它,则使用一个stop()
方法,该方法设置一些标志或类似标志来指示终止。对它的调用必须从另一个线程进行,因为第一个线程在服务时仍然保存在service()
中
底线:似乎尚未实施。事实上,这似乎根本不可能/无法预见:
正如您所注意到的,没有stop()
,所有三个服务器的实现目前都在无限循环,而true则是
通常的方法是,假设有人要添加它,则使用一个stop()
方法,该方法设置一些标志或类似标志来指示终止。对它的调用必须从另一个线程进行,因为第一个线程在服务时仍然保存在service()
中
底线:似乎尚未实施。非常感谢。什么标志信号可以用来通知另一个线程的终止?在无休止的循环中似乎没有相关的检测。确切地说,“底线:似乎还没有实现”。。。但我们接受拉取请求:-)非常感谢。什么标志信号可以用来通知另一个线程的终止?在无休止的循环中似乎没有相关的检测。确切地说,“底线:似乎还没有实现”。。。但我们接受拉取请求:-)