Parallel Programming in Python with async/await and threads Course

Course Summary

Python's async and parallel programming support is highly underrated. In this course, you will learn the entire spectrum of Python's parallel APIs. We will start with covering the new and powerful async and await keywords along with the underpinning module: asyncio. Then we'll move on to Python's threads for parallelizing older operations and multiprocessing for CPU bound operations. We'll close out the course with a host of additional async topics such as async Flask, task coordination, thread safety, and C-based parallelism with Cython.

What students are saying

*Finally* finished working through Michael Kennedy's "Python Async Techniques" course today! (had it queued for months). If you're looking for a single all-you-need-to-know for concurrent programming in Python then this is def'ly a go-to 👌🏽
-- Arvinda

Source code and course GitHub repository

github.com/talkpython/async-techniques-python-course

What's this course about and how is it different?

This is the definitive course on parallel programming in Python. It covers the tried and true foundational concepts such as threads and multiprocessing as well as the most modern async features based on Python 3.7+ with async and await.

In addition to the core concepts and APIs for concurrent programming, you will learn best practices and how to choose between the various APIs as well as how to use them together for the biggest advantage.

In this course, you will:

  • See how concurrency allows improved performance and scalability
  • Build async-capable code with the new async and await keywords
  • Add asynchrony to your app without additional threads or processes
  • Work with multiple threads to run I/O bound work in Python
  • Use locks and thread safety mechanisms to protect shared data
  • Recognize a dead-lock and see how to prevent them in Python threads
  • Take full advantage of multicore CPUs with multiprocessing
  • Unify the thread and process APIs with execution pools
  • Add massive speedups with Cython and Python threads
  • Create async view methods in Flask web apps
  • And lots more

View the full course outline.

Who is this course for?

Anyone who would like to write Python code that does more, scales better, and takes better advantage of modern, multicore CPUs. Whether you're a web developer or data scientists, you will find a host of techniques to do more faster.

The course is not a beginner Python course, so students with little to no Python language experience should take a foundational course first. We recommend our Python Jumpstart by Building 10 Apps as a prerequisite if needed.

Concepts backed by concise visuals

While exploring a topic interactively with demos and live code is very engaging, it can mean losing the forest for the trees. That's why when we hit a new topic, we stop and discuss it with concise and clear visuals.

Here's an example of introducing the concept of temporarily invalid states in thread safety.

Example: Concepts backed by concise visuals

Follow along with subtitles and transcripts

Each course comes with subtitles and full transcripts. The transcripts are available as a separate searchable page for each lecture. They also are available in course-wide search results to help you find just the right lecture.

Each course has subtitles available in the video player.

Get hands-on for almost every chapter

Learning to code is an interactive experience. That's why it's important to write async code and explore the apps we build during this course. Most chapters have code samples stored in the GitHub repo saved at various stages throughout the chapter. This means you can grab whichever one you want and start trying the code for yourself.

Who am I? Why should you take my course?

Who is Michael Kennedy?

My name is Michael, nice to meet you. ;) There are a couple of reasons I'm especially qualified to teach you Python.

 1. I'm the host of the #1 podcast on Python called Talk Python To Me. Over there, I've interviewed many of the leaders and creators in the Python community. I bring that perspective to all the courses I create.

 2. I've been a professional software trainer for over 10 years. I have taught literally thousands of professional developers in hundreds of courses throughout the world.

 3. Students have loved my courses. Here are just a few quotes from past students of mine.

"Michael is super knowledgeable, loves his craft, and he conveys it all well. I would highly recommend his training class anytime." - Robert F.
"Michael is simply an outstanding instructor." - Kevin R.
"Michael was an encyclopedia for the deep inner workings of Python. Very impressive." - Neal L.

Free office hours keep you from getting stuck

One of the challenges of self-paced online learning is getting stuck. It can be hard to get the help you need to get unstuck.

That's why at Talk Python Training, we offer live, online office hours. You drop in and join a group of fellow students to chat about your course progress and see solutions via screen sharing.

Just visit your account page to see the upcoming office hour schedule.

Is this course based on Python 3 or Python 2?

This course is based upon Python 3. Python 2 is officially unsupported as of January 1st, 2020 and we believe that it would be ill-advised to teach or learn Python 2. This course is, and has always been, built around Python 3.

The time to act is now

The dawn of Python's full async power is here. It's time to gain all its superpowers to build your next Python project faster, better, stronger.

Course Outline: Chapters and Lectures

Welcome to the course
9:43
Course introduction
1:27
Async for taking full advantage of modern CPUs
1:51
Topics covered
4:52
Student prerequisites
0:44
Meet your instructor
0:49
Setup and following along
5:57
Do you have Python 3?
1:40
Getting Python 3
0:39
Recommended text editor
0:53
PyCharm Pro for Free
0:30
Hardware requirements
1:13
Get the source code
1:02
Why async?
26:24
Async for computational speed
3:42
Demo: Why you need async for speed
3:54
An upper bound for async speed improvement
3:53
Async for scalability
1:49
Concept: Visualizing a synchronous request
3:34
Concept: Visualizing an asynchronous request
2:14
Python's async landscape
4:25
Why threads don't perform in Python
2:53
async and await with asyncio
56:33
Python async landscape: asyncio
1:15
I/O-driven concurrency
3:51
Demo: Understanding basic generators
9:05
Demo: The producer-consumer app
3:08
Demo: Make the producer-consumer async
5:36
Demo: Make the producer-consumer async (methods)
7:17
Concept: asyncio
1:17
Performance improvements of producer consumer with asyncio
1:46
Faster asyncio loops with uvloop
4:42
Let's do some real work
1:07
Synchronous web scraping
3:08
async web scraping
9:16
Concept: async web scraping
1:24
Other async-enabled libraries
3:41
Threads
32:24
Python async landscape: Threads
1:07
Visual of thread execution
1:12
How to choose between asyncio and threads
2:33
Demo: hello threads
4:59
Demo: Waiting on more than one thread
3:52
Demo: Something productive with threads
3:10
Concept: Thread API
1:41
Concept: Tips for multiple threads
0:41
Cancelling threads with user input
6:02
Concept: Timeouts
1:21
Demo: Attempting to leverage multiple cores with threads
5:46
Thread safety
28:30
Python async landscape: Thread Safety landscape
0:46
Threads are dangerous
1:28
Visualizing the need for thread safety
3:35
Demo: An unsafe bank
5:04
Demo: Make the bank safe (global)
4:35
Demo: A missed lock in our bank (global)
1:45
Demo: Make the bank safe (fine-grained)
5:50
Demo: Breaking a deadlock
3:44
Concept: Basic thread safety
1:43
Leveraging CPU cores with multiprocessing
12:29
Python async landscape: multiprocessing
1:02
Introduction to scaling CPU-bound operations
1:52
Demo: Scaling CPU-bound operations with multiprocessing
4:55
Concept: Scaling CPU-bound operations
1:21
Multiprocessing return values
2:19
Concept: Return values
1:00
Common APIs with execution pools
14:27
Python async landscape: Execution pools
1:51
Demo: Executor app introduction
2:21
Demo: Executor app (threaded-edition)
6:45
Demo: Executor app (process-edition)
1:47
Concept: Execution pools
1:43
Built on asyncio
33:03
Python async landscape: asyncio derivatives
1:32
Why do we need more libraries?
4:31
Introducing unsync
2:22
Demo: unsync app introduction
4:22
Demo: unsync app for mixed-mode parallelism
5:54
Concept: Mixed-mode parallelism with unsync
3:10
Introducing Trio
1:11
Demo: Starter code for Trio app
1:01
Demo: Converting from asyncio to Trio
4:53
Demo: Cancellation with Trio
1:56
Concept: Trio nurseries
1:16
The trio-async package
0:55
asyncio-based web frameworks
31:38
Python async landscape: Async web
1:20
Review: Request latency again
1:31
Demo: Introducing our Flask API
5:01
There is no async support for Flask
1:51
Demo: Introducing Quart for async Flask
1:06
Demo: Converting from Flask to Quart
1:30
Demo: Making our API async
4:39
Demo: An async weather endpoint
1:33
Concept: Flask to Quart
2:37
Load testing web apps with wrk
2:00
A note about rate limiting with external services
3:16
Performance results
3:33
Remember to run on an ASGI server
1:41
Parallelism in C with Cython
30:37
Python async landscape: Cython
1:31
C and Python are friends
1:45
Why Cython
3:00
Cython syntax compared
2:26
Demo: Hello Cython
5:36
Concept: Getting started with Cython
1:11
Demo: Fast threading with cython (app review)
2:46
Demo: Fast threading with Cython (hotspot)
1:40
Demo: Fast threading with Cython (conversion)
2:19
Demo: Fast threading with Cython (GIL-less)
4:06
Demo: Fast threading with Cython (int overflow issues)
2:53
Concept: Cython's nogil
1:24
Course conclusion and review
17:58
The finish line
0:35
Review: Why async?
2:01
Review: asyncio
1:04
Review: Threads
1:19
Review: Thread safety
2:16
Review: multiprocessing
2:13
Review: Execution pools
1:44
Review: Mixed-mode parallelism
1:58
Review: Coordination with Trio
1:35
Review: Async Flask
1:18
Review: Cython
1:38
Thanks and goodbye
0:17
Buy for $53 + tax Bundle and save 85% Team Gift

Questions? Send us an email: contact@talkpython.fm

Talk Python's Mastodon Michael Kennedy's Mastodon