How to implement the request as non-blocked

Hi, I used flask and non-blocked between requests.But,when I use sanic,I found that it was blocked between the requests. I want to achieve the same effect as the flask,what am I going to do?

Thanks!

Sanic will run single threaded (well, really all python does because of the GIL). Sanic’s concurrency model is based upon asyncio. Therefore, in order to have non-blocking requests, you need to use tools like async enabled data access tools, HTTP clients, disk reading, etc. Anything that does I/O should be done with an async library.

This is how Sanic can be “faster” than Flask. In actuality, the speed of the code is the same. The library does not change the performance of your machine. But asyncio is a more efficient use of compute time by allowing for context switching on io operations. If you’re unfamiliar with how this works, I might suggest taking some time to read about asyncio.

Thanks! Well,are there some examples to reference to?

This is probably a good start. Haven’t read it so I cannot vouch for the content, but usually they put out good articles.

Thank you very much! I will go and see it .