The following code takes only 2 seconds when 10 requests are requested at the same time (ab -n 10 -c 10 http://127.0.0.1:5000/
). Shouldn't it be 10 seconds because of GIL?
from flask import Flask
from time import sleep
app = Flask(__name__)
@app.route("/")
def hello_world():
sleep(1)
return "<p>Hello, World!</p>"
if __name__ == "__main__":
app.run()
# ab -n 10 -c 10 http://127.0.0.1:5000/
# This is ApacheBench, Version 2.3
# Server Software: Werkzeug/2.0.1
# Server Hostname: 127.0.0.1
# Server Port: 5000
# Concurrency Level: 10
# Time taken for tests: 2.021 seconds
# Complete requests: 10
Is sleep()
blocking? And the code doesn't use asyncio even if it yields the control when calling sleep()
?