我希望我的flask应用程序能够同时处理多个调用。
我用下面的代码测试了使用threaded=True
或{
from flask import Flask, Response, stream_with_context
from time import sleep
app = Flask(__name__)
def text_gen(message):
for c in message:
yield c
sleep(1)
@app.route("/")
def hello():
stream = text_gen('Hello World')
return Response(stream_with_context(stream))
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8080, debug=True, threaded=True)
{a1}是对的。在
我在googlechrome上调试了两个标签。显然,Chrome正试图通过对两个标签使用相同的插座来实现智能化。启动Chrome时如何使用
-socket-reuse-policy
标志更改Chrome处理。在一种更简单的测试方法是在每个选项卡中使用不同的主机名,或者使用
curl -N
(-N
标志表示没有缓冲区来查看流)。这样做确实起到了预期的效果。在相关问题 更多 >
编程相关推荐