我尝试了以下实现,一个是'reactor.stop()',另一个是'reactor.stop':
reactor.listenTCP(
host_port, server.Site(PageFactory())
).stopListening()
reactor.callFromThread(reactor.stop())
while reactor.running:
print("running")
time.sleep(0.1)
if not reactor.running:
print("STOPPED!!!!!")
上面在“reactor.stop()”行引发异常: “第1016行,在callFromThread中 断言可调用(f),“%s不可调用”%(f,) AssertionError:None是不可调用的“ 尽管我使用了'from twisted.internet import reactor',而且许多人似乎使用reactor.stop()。所以不能打印“running”或“STOPPED!!!”
reactor.listenTCP(
host_port, server.Site(PageFactory())
).stopListening()
reactor.callFromThread(reactor.stop)
while reactor.running:
print("running")
time.sleep(0.1)
if not reactor.running:
print("STOPPED!!!!!")
上面无休止的打印“运行”,所以反应堆永远不会停止
目前没有回答
相关问题 更多 >
编程相关推荐