7. At the beginning there were threads..

In our first talk about this subject, “Talk #1 - Concurrency with Threads and Futures, Feb 8th, 2020.”, we discussed the evolution of concurrency in Python.

We started by analyzing Chapter 17, and the first part of Chapter 18 of Luciano Ramalho’s book “Fluent Python” [6]. In Chapter 17 “Concurrency and Features”, Luciano starts by explaining a sequential download. It is, of course, necessary that we see a sequential example and how we could later improve it using concurrency.

Luciano starts Chapter 18 with an example of Threads, and later move us to coroutines and finally async I/O. We discussed Chapter 17 and used the treads example in Chapter 18 to learn about Threads and Futures. We discussed Raymond Hettinger [12] talk, “Keynote on Concurrency, PyBay 2017”, where we learned the complexity and perils that lure on the Threads world.

Finally, we were able to arrive to below evolutionary conclusion in Table 1. If you want to know more about this, we encourage you to read our talk and the resources mentioned.

Table 1. Concurrency in Python: Threads , Futures and Async I/O

Python

Python 3.2/ 2011

Python 3.4/2014 Created by Guido

current.futures ThreadpoolExecutor Context Manager

asyncio

Threads, Locks,Semaphore,Event,Timer,Queue

Threads, Locks,Semaphore,Event,Timer,Queue

Coroutines, AsyncIO not blocking loops, call backs

Multi Thread Processing

Multi Thread Processing

Single Thread Processing

We are here, one month later , to talk about async I/O, far away from the thread and blocked world we discussed in February, entering into a new universe of cooperation multitasking and event loops.

But then, we wonder, what is Async I/O and what does Python have to do with it?