有如下代码,在我的预想中,使用两个浏览器窗口(A,B 窗口)同时访问 http://127.0.0.1:8000,等到两个页面加载完成总耗时应该接近是 10 秒,但是实际上需要 20 秒,A 窗口 10 秒加载完毕,再过 10 秒 B 窗口加载完毕。import asynciofrom sanic import Sanic, response
app = Sanic(__name__)@app.route('/')async def test(request):
await asyncio.sleep(10) # 休眠 10 秒
return response.json({'test': True})if __name__ == '__main__':
app.run(port=8000, debug=True)
添加回答
举报
0/150
提交
取消