For I/O-bound workloads, there are exactly (only!) two reasons to use async-based concurrency over thread-based concurrency:
- Asyncio offers a safer alternative to preemptive multitasking (i.e., using threads), thereby avoiding the bugs, race conditions, and other nondeterministic dangers that frequently occur in nontrivial threaded applications.
- Asyncio offers a simple way to support many thousands of simultaneous socket connections, including being able to handle many long-lived connections for newer technologies like WebSockets, or MQTT for Internet of Things (IoT) applications.
摘自 Using Asyncio in Python 昨天剛好看了這本書 如果感興趣且能看到的話可以看下 還是挺不錯的 http://shop.oreilly.com/product/0636920320876.do