【发布时间】:2016-10-25 18:21:50
【问题描述】:
应要求重新打开此问题 (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,单击链接,然后点击浏览器中的停止按钮。睡眠结束后,您应该会看到异常。 睡眠对于模拟服务器上发生的任何类型的活动是必要的。可能只有几秒钟:如果用户设法离开页面 - Flask 将会崩溃。
socket.error: [Errno 10053] 已建立的连接被 主机中的软件
为什么服务器停止为应用程序提供服务?我可以为我的 Flask 应用程序使用什么其他服务器来避免这种情况?
【问题讨论】:
-
如果您通过推荐的方式之一(即 apache 或 nginx)提供它,这可能根本不会成为问题 ...
-
我之前用完全相同的答案回答了一个类似的问题,所以我复制了这个(另一个问题是关于并发请求但停止
curl然后导致管道回溯中断)。