【发布时间】:2023-03-15 13:08:02
【问题描述】:
我正在运行 Tornado 网络服务器来发送 GET 和 POST 请求。我希望能够将其关闭以对其进行修改,并在完成测试后启动它。但我不能,使用的端口永远在使用......
def startTornado():
application = tornado.web.Application([
(r"/", MainHandler),
])
application.listen(80)
tornado.ioloop.IOLoop.instance().start()
print "Server is running"
def stopTornado():
ioloop = tornado.ioloop.IOLoop.instance()
ioloop.add_callback(ioloop.stop)
print "Asked Tornado to exit"
if __name__ == "__main__":
#stopTornado()
startTornado()
我检查了网络上的所有答案,但它对我没有帮助。
ioloop = tornado.ioloop.IOLoop.instance()
ioloop.add_callback(ioloop.stop)
不关闭端口。它仍在使用中:
TCP 0.0.0.0:80 PC-1:0 LISTENING
[python.exe]
有人有想法吗?
【问题讨论】: