At Open Source Bridge and PyGotham in 2015, and at SCALE14x, I demonstrated that you can code a Python 3 async framework in under an hour. I start the demo by writing a callback-based async framework, built on non-blocking sockets and a simple event loop. Then I adapt the framework to use generator-based coroutines, which are cleaner than callbacks but still more efficient than threads for async I/O.

Here's the code I demonstrated.

The material for this demo is adapted from a chapter I wrote with Guido van Rossum for an upcoming book in the Architecture of Open Source Applications series.

Ben Darnell wrote a marvelous guide to coroutines in Tornado. For advanced coroutine patterns see "Refactoring Tornado Coroutines" and my locks and queues for Tornado.

Image: Popular Science, 1837.