top band

Saturday 5:10 p.m.–5:40 p.m.

Lessons learned with asyncio ("Look ma, I wrote a distributed hash table!")

Nicholas Tollervey

Audience level:
Python Libraries


This talk introduces the asyncio module. I'll cover what it's for, how it works and describe how I used it to write a real-world networked application (a distributed hash table). We'll explore the event loop, co-routines, futures and networking with examples from my code. This won't be an exhaustive exposition. Rather, attendees will grasp enough of asyncio to continue with their own studies.


This is an introduction to the (relatively) new asyncio module that arrived in the standard library of Python 3.4. The documentation states that asyncio, > "...provides infrastructure for writing single-threaded concurrent code using coroutines, multiplexing I/O access over sockets and other resources, running network clients and servers, and other related primitives." While we probably all understand much of the theoretical terminology in this definition, I intend to explore and illustrate what this means _in practice_ (with examples from a real-world networked application I have written using asyncio). To this end, I will assume no previous knowledge of asyncio and present: - A description of the problem asyncio helps to solve; - An introduction to core asyncio concepts such as the event loop, co-routines, futures and network abstractions; - A description of how such concepts fit together; - The story of how I rewrote my distributed hash table library with asyncio (from Twisted); - Examples of real-world asyncio development: unit-testing, what's easy, what's hard, when shouldn't you use asyncio? - Where to find out more. By the end of this introductory talk I hope you will have a desire to learn more about asyncio and perhaps give it a try in your own projects.
bottom band background