<分区>
根据要求重新打开这个问题(error: [Errno 10053]),提供最小的可测试示例:
import time
from flask import Flask, render_template
app = Flask(__name__, static_folder='static', template_folder='templates')
@app.route('/')
def main():
return render_template('test.html')
@app.route('/test')
def test():
print "Sleeping. Hit Stop button in browser now"
time.sleep(10)
print "Woke up. You should see a stack trace from the problematic exception below."
return render_template('test.html')
if __name__ == '__main__':
app.run()
HTML:
<html>
<body>
<a href="/test">test</a>
</body>
</html>
指南: 运行应用程序,导航到 localhost:port,单击链接,然后单击浏览器中的停止按钮。 sleep 结束后,您应该会看到异常。 sleep 是模拟服务器上发生的任何类型事件所必需的。这可能只是几秒钟:如果用户设法离开页面 - Flask 将崩溃。
socket.error: [Errno 10053] An established connection was aborted by the software in your host machine
为什么服务器停止为应用程序提供服务?我可以为我的 Flask 应用程序使用什么其他服务器来避免这种情况?