at the same time) https://en.wikipedia.org/wiki/C10k_problem • One thread per each connection is not practical • Use too much memory • Context switch overhead out weight payload • Processing I/O with event loop is more efficient
2013 • Part of standard library since Python 3.4 • You can install from PyPi asyncio for Python 3.3 • Writing single-threaded concurrent code using coroutines, multiplexing I/O access over sockets and other resources
write async code without writing callback function • Construct a coroutine is like construct a generator, no code execution on creation time • Coroutine is executed when event loop iterate over it • Coroutine is suspended when waiting for event