Chapter 4. 20 Asyncio Libraries You Aren’t Using (But…Oh, Never Mind)
In this chapter, we look at case studies using the new Python features for async programming. We’ll be making use of several third-party libraries, as you will in your own projects.
The title of this chapter is a play on the
title of a previous book I wrote called
20
Python Libraries You Aren’t Using (But Should) (O’Reilly). Many of those
libraries will also be useful in your asyncio-based applications,
but this chapter focuses on libraries that have been
designed specifically for the new async features in Python.
It is difficult to present asyncio-based code in short snippets. As
you have seen in all the previous code samples in the book, I’ve
tried to make each example a complete, runnable program, because
application lifetime management is a core consideration for
using async programming correctly.
For this reason, most of the case studies in this chapter will be somewhat larger, in terms of lines of code, than is usual for such a book. My goal in using this approach is to make the case studies more useful by giving you a “whole view” of an async program rather than leaving you to figure out how detached fragments might fit together.
Note
Some of the code samples in this chapter compromise on style in order to save space. I like PEP8 as much as the next Pythonista, but practicality beats purity!
Streams (Standard Library)
Before looking at third-party libraries, let’s begin with the standard library. The ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access