Trivial question and probably been asked a few times. I understand that Sanic can run on Windows (i.e. detect the lack of uvloop, but never the less fallback and press on).
My question is, will it still serve requests asynchronously on Windows....? The answer appears to be yes - after all it is an async framework.
However, say i have an endpoint which just sleeps i.e. asyncio.sleep(10) and returns. If i call this end point (/) twice in quick succession - the first response comes back in 10 seconds and only then does the processing of the 2nd request start. So the 2nd request comes back after about 20 seconds (synchronous behavior).
Now, If i did the same thing i.e. run a request on 2 independent endpoints say (/i and /) - they both start processing as soon as the request arrives, the first one takes 10 seconds before responding (as expected), and then the 2nd one comes back immediately after the first (asynchronous behavior).
I was sort of expecting asyncio tasks of the request handler to be farmed off to the event loop and hence have the same async behaviour even when calling the same endpoint twice quick succession.
Am i missing something here?
from sanic import Sanic
from sanic.response import json
import asyncio
app = Sanic("X")
@app.route("/")
async def test(request):
print("request rcvd")
await asyncio.sleep(10)
return json({"hello": "world"})
@app.route("/i")
async def test(request):
print("request /i rcvd")
await asyncio.sleep(10)
return json({"hello": "i"})
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)