9 Useful Articles about Asyncio

Posted on Fri, 20 Oct 2017 in Python

asyncio is a useful library. However, it is not so easy to understand how to work with it. Documentation isn't enough. We need more examples. We need more explanations. The last couple of weekends I spent experimenting with this library. After that, I add some interesting articles into my Pocket. Here are some of them.

#1 Exploring Python 3’s Asyncio by Example

A quick intro into asyncio and aiohttp via several short examples. As the author notices, it shows only a tip of the iceberg. Examples in this article are as simple as possible. However, decorators are used in this article. It is a quite old article.

#2 Fast scraping in python with asyncio

This article describes an example implementation of a script that extracts magnet links from web pages. This is also a quite old article. I include in the list because of "the bonus track". The author shows how to limit the number of queries. However, I think it is better to limit the number of queries by aiohttp setting.

#3 Wrapping Subprocesses in Asyncio

In this article, a very interesting case is described. The author uses asyncio to handle subprocess stdout. I didn't even think that it is possible to use asyncio to do this. However, the author shows a quite interesting code.

#4 A Web Crawler With asyncio Coroutines by A. Jesse Jiryu Davis and Guido van Rossum

This is a detailed explanation how to write web crawler using Python and asyncio. In my opinion, there are too much unnecessary explanations and digressions. For example, why do authors explain how generators work? In general, this article is not the best resource about asyncio. I left it the list because of one of the authors.

#5 Making 1 million requests with python-aiohttp by Paweł Miech

I think the author of this article writes in Go. Why? In Go-world it is OK to write benchmarks for everything. In this article, he tests aiohttp speed limits. By the way, it is 111,111 absolutely useless queries by minute on his hardware. Cool! Nevertheless, it is a very useful article. The author shows some common aiohttp pitfalls and explains how to deal with them.

#6 Python asyncio cheatsheet

How to use asyncio by examples. Only code. I doubt you can find a better place to start.

#7 I don't understand Python's Asyncio by Armin Ronacher

Armin complains about the complexity of asyncio. It's true, you have to know a lot of things to use this library 100%. However, my opinion is that the most difficulties will disappear when developers find right approaches how to use it.

#8 AsyncIO for the Working Python Developer by Yeray Diaz

Yet another asyncio tutorial. All examples are written in the new syntax. Each example has a good explanation.

#9 Asyncio Coroutine Patterns: Beyond await by Yeray Diaz

This is another article from the same author. This time it is for more experienced developers. It covers several patterns of using asyncio: Recursive coroutines, Fire and forgets, and Periodic coroutines.

Bonus: Asyncio: An Introduction by Mike Driscoll