有如下代碼,在我的預想中,使用兩個瀏覽器窗口(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
提交
取消
