Environmental assumptions
> = Python 3.5
Linux
advantage
- This function is abnormal for asynchronous I/O tasks
- Programming model is simpler and less burdensome:
- Get an Event loop using Asyncio
- And then we plug something into this loop (coroutine)
- The operating system still sees single threading, but from a macro perspective it sees “multi-concurrency” (every language is pretty much like this: implementing a multi-threaded model in user mode).
disadvantages
- The ecology is immature (although there is AIO-Libs), and it would be nice if libraries like Requests had corresponding implementations (and high popularity)
- There is a premise that an App must be asynchronous from front to back, which is burdensome for many legacy projects
Contrast with GEvent + Python 2
- Many projects are Python 2 based, and using gEvent is very effective
- The only worry is that gEvent will have a lot of patches (hack standard library), and what we see is a black box
- Gevent is not necessarily less efficient than Asyncio + Async def
(Actually, I’m a little fan of GEvent. Our project uses gEvent a lot and the effect is quite good. Why not use it?)
How to use
- Asyncio as our framework (I prefer what the standard library has) and async def/await as the basic design tool
- Use the various libs in AIO-Libs (asynchronous from start to finish!)