PyCon Pittsburgh. April 15-23, 2020.

Tutorial: Python Concurrency: from beginner to pro

Presented by:

Santiago Basulto, Martin Zugnoni


This is the ultimate concurrency tutorial. Aimed for beginners, we won’t skip the ugly parts (OS low level and computer science concepts). In this tutorial you’ll learn:

  • what is concurrency and why you need it?
  • what’s the role of the OS in computing and parallelism?
  • how processes work, what fundamental OS structures are used
  • what are threads, how are they created and what’s their scope
  • what modules does Python offer for multithreading (_thread, threading, concurrent.futures) and what’s the difference between them, the same for multiprocessing (subprocess, multiprocessing or concurrent.futures).
  • what are race conditions? how to avoid them with synchronization primitives and threadsafe collections
  • What is the GIL? In which situations will it affect our code?

This tutorial will include coding examples for all the concepts in it, along with two main activities, in which we’ll be writing a web server both using multithreading and multiprocessing!

At the end of this tutorial, you’ll feel confident answering the following questions:

  • Should I even use concurrency?
  • If I want to use concurrency, threads or processes?
  • How can I make sure my code is safe?


Watch on YouTube