Uvloop – Ultra fast implementation of asyncio event loop on top of libuv
github.com
github.com
I also recommend to read our blog posts about uvloop and asyncio on magic.io
While using async is much easier with the new async/await syntax compared to traditional async solutions like twisted, tornado etc., a lot of popular database connectors and ORMs do not support async currently.
Even if the libraries a person needs are present at the moment, there's always the chance that a library maybe required in the future that does not support async and it may not be feasible to write a replacement(either due to the person's lack of expertise or due to lack of funds to hire someone else to write it).
In such a case, would using a traditional library by spawning threads to run any blocking operation be a good stop-gap solution(until an async replacement comes along)?
This has been a nightmare in C# which pioneered async/await - a lot of developers are struggling with footguns from mixing sync and async code.
Ryan Dhal said that he picked JavaScript for Node because he was afraid of this and wanted a language without synchronous APIs already built in.
I think Python 3.5+ async/await is fantastic don't get me wrong - but if you want to mix and match I'd recommend getting a second server that runs the synchronous framework and then communicating over network (REST HTTP for example) between the completely asynchronous server and the one running the thread pool.
The big difference is that C# supports both multithreading and parallelism out of the box. Python has multithreading but with a GIL, nodejs has none of the 2.
Using async makes sense where you want to handle 100s/1000s of long-open connections (websockets for instance). Spawning a lot of threads/processes can be very expensive, and will lead to suboptimal QoS.
> While using async is much easier with the new async/await syntax compared to traditional async solutions like twisted, tornado etc., a lot of popular database connectors and ORMs do not support async currently.
Good news is that you can have most of your application written in Django (or other traditional web framework), using async to implement specific API endpoints.
For the record, asyncio provides this ability out-of-box using the AbstractEventLoop.run_in_executor coroutine.
At work, we use Flask+Gevent for our HTTP API. It's worked pretty well so far!
I don't think it makes a lot of sense to run Django/Flask on top of uvloop--the performance benefits will be negligible, if any.
> If I have a plan to develop a web api base on Uvloop how do I start?
In a few months we plan to opensource a web micro-framework based on uvloop & httptools. Right now you can use aiohttp which is quite mature.
I use aiohttp and uvloop fairly heavily, though I've not formally benched with/without uvloop in quite some time.
Are there any benefits to using uvloop vs curio?