Skip to main content
CF

Async Techniques and Examples in Python

5h 2m 11s
English
Paid

Unlock the power of Python's async and parallel programming with this comprehensive course. Designed for both beginners and experienced developers, you'll explore the full range of Python's parallel APIs, from the modern async and await keywords to advanced multiprocessing techniques. Throughout the course, you'll also delve into async Flask, thread safety, and even C-based parallelism with Cython.

Course Content Overview

Source Code and GitHub Repository

Access the course materials and source code on our dedicated GitHub repository:

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

Course Highlights

Discover why this course stands out in the realm of parallel programming in Python. It combines foundational concepts like threading and multiprocessing with cutting-edge asynchronous programming techniques introduced in Python 3.7+.

Learn not only the core APIs, but also the best practices for applying them effectively. You'll gain insights into choosing and combining these techniques to achieve maximum performance.

What You Will Learn

  • Enhance performance and scalability through concurrency
  • Develop async code using the new async and await keywords
  • Incorporate asynchrony without extra threads or processes
  • Utilize threads to manage I/O bound tasks efficiently
  • Implement locks and thread safety mechanisms to safeguard data
  • Identify and prevent deadlocks in Python threads
  • Maximize multicore CPU usage with multiprocessing
  • Integrate thread and process APIs using execution pools
  • Achieve significant speedups with Cython and Python threads
  • Develop async view methods in Flask web applications
  • And much more

Target Audience

This course is designed for anyone looking to optimize their Python code for better performance and scalability, leveraging modern multicore CPUs. Whether you are a web developer or a data scientist, this course offers a wealth of techniques to enhance your programming capabilities.

About the Author: Talk Python Training

Talk Python Training thumbnail

Talk Python Training is the paid course platform of Michael Kennedy, the host of the long-running Talk Python To Me podcast — one of the most-listened-to podcasts in the Python ecosystem. The course platform extends Michael's interview-based knowledge of the field into structured video courses taught by Michael and a curated set of guest instructors.

The course catalog covers the full Python landscape: web development with Django, Flask, FastAPI, and the broader async-Python stack; data science and pandas; LLM / RAG application development; testing and CI/CD; deployment patterns; the data-engineering side of Python; and a long list of practical Python patterns aimed at working developers. Few platforms cover the language with this much breadth from inside the Python community itself.

The CourseFlix listing under this source carries over 18 Talk Python Training courses spanning that range. Material is paid; Talk Python Training runs on per-course pricing on the original platform. Courses are aimed at developers using Python as a serious primary language rather than as a scripting tool.

Watch Online 113 lessons

This is a demo lesson (10:00 remaining)

You can watch up to 10 minutes for free. Subscribe to unlock all 113 lessons in this course and access 10,000+ hours of premium content across all courses.

View Pricing
0:00
/
#1: Course introduction
All Course Lessons (113)
#Lesson TitleDurationAccess
1
Course introduction Demo
01:27
2
Async for taking full advantage of modern CPUs
01:52
3
Topics covered
04:53
4
Student prerequisites
00:45
5
Meet your instructor
00:49
6
Video player: A quick feature tour
02:05
7
Do you have Python 3?
01:40
8
Getting Python 3
00:39
9
Recommended text editor
00:54
10
Hardware requirements
01:14
11
Get the source code
01:02
12
Async for computational speed
03:43
13
Demo: Why you need async for speed
03:55
14
An upper bound for async speed improvement
03:53
15
Async for scalability
01:50
16
Concept: Visualizing a synchronous request
03:34
17
Concept: Visualizing an asynchronous request
02:15
18
Python's async landscape
04:25
19
Why threads don't perform in Python
02:53
20
Python async landscape: asyncio
01:16
21
I/O-driven concurrency
03:51
22
Demo: Understanding basic generators
09:05
23
Demo: The producer-consumer app
03:08
24
Demo: Make the producer-consumer async
05:36
25
Demo: Make the producer-consumer async (methods)
07:17
26
Concept: asyncio
01:18
27
Performance improvements of producer consumer with asyncio
01:47
28
Faster asyncio loops with uvloop
04:38
29
Let's do some real work
01:07
30
Synchronous web scraping
03:09
31
async web scraping
09:17
32
Concept: async web scraping
01:25
33
Other async-enabled libraries
03:42
34
Python async landscape: Threads
01:07
35
Visual of thread execution
01:13
36
How to choose between asyncio and threads
02:34
37
Demo: hello threads
05:00
38
Demo: Waiting on more than one thread
03:53
39
Demo: Something productive with threads
03:10
40
Concept: Thread API
01:42
41
Concept: Tips for multiple threads
00:42
42
Cancelling threads with user input
06:02
43
Concept: Timeouts
01:22
44
Demo: Attempting to leverage multiple cores with threads
05:46
45
Python async landscape: Thread Safety landscape
00:47
46
Threads are dangerous
01:28
47
Visualizing the need for thread safety
03:35
48
Demo: An unsafe bank
05:05
49
Demo: Make the bank safe (global)
04:35
50
Demo: A missed lock in our bank (global)
01:45
51
Demo: Make the bank safe (fine-grained)
05:50
52
Demo: Breaking a deadlock
03:45
53
Concept: Basic thread safety
01:43
54
Python async landscape: multiprocessing
01:03
55
Introduction to scaling CPU-bound operations
01:52
56
Demo: Scaling CPU-bound operations with multiprocessing
04:56
57
Concept: Scaling CPU-bound operations
01:22
58
Multiprocessing return values
02:19
59
Concept: Return values
01:00
60
Python async landscape: Execution pools
01:51
61
Demo: Executor app introduction
02:22
62
Demo: Executor app (threaded-edition)
06:45
63
Demo: Executor app (process-edition)
01:47
64
Concept: Execution pools
01:43
65
Python async landscape: asyncio derivatives
01:32
66
Why do we need more libraries?
04:32
67
Introducing unsync
02:22
68
Demo: unsync app introduction
04:22
69
Demo: unsync app for mixed-mode parallelism
05:55
70
Concept: Mixed-mode parallelism with unsync
03:11
71
Introducing Trio
01:11
72
Demo: Starter code for Trio app
01:02
73
Demo: Converting from asyncio to Trio
04:54
74
Demo: Cancellation with Trio
01:57
75
Concept: Trio nurseries
01:17
76
The trio-async package
00:56
77
Python async landscape: Async web
01:21
78
Review: Request latency again
01:32
79
Demo: Introducing our Flask API
05:02
80
There is no async support for Flask
01:51
81
Demo: Introducing Quart for async Flask
01:06
82
Demo: Converting from Flask to Quart
01:30
83
Demo: Making our API async
04:39
84
Demo: An async weather endpoint
01:34
85
Concept: Flask to Quart
02:37
86
Load testing web apps with wrk
02:01
87
A note about rate limiting with external services
03:17
88
Performance results
03:33
89
Remember to run on an ASGI server
01:42
90
Python async landscape: Cython
01:32
91
C and Python are friends
01:45
92
Why Cython
03:00
93
Cython syntax compared
02:27
94
Demo: Hello Cython
05:37
95
Concept: Getting started with Cython
01:12
96
Demo: Fast threading with cython (app review)
02:47
97
Demo: Fast threading with Cython (hotspot)
01:40
98
Demo: Fast threading with Cython (conversion)
02:20
99
Demo: Fast threading with Cython (GIL-less)
04:06
100
Demo: Fast threading with Cython (int overflow issues)
02:53
101
Concept: Cython's nogil
01:25
102
The finish line
00:35
103
Review: Why async?
02:01
104
Review: asyncio
01:04
105
Review: Threads
01:19
106
Review: Thread safety
02:17
107
Review: multiprocessing
02:14
108
Review: Execution pools
01:45
109
Review: Mixed-mode parallelism
01:59
110
Review: Coordination with Trio
01:35
111
Review: Async Flask
01:18
112
Review: Cython
01:39
113
Thanks and goodbye
00:17
Unlock unlimited learning

Get instant access to all 112 lessons in this course, plus thousands of other premium courses. One subscription, unlimited knowledge.

Learn more about subscription

Related courses

Frequently asked questions

What prerequisites are needed for this course?
Students should have a basic understanding of Python programming and be comfortable with fundamental programming concepts. While the course is designed for both beginners and experienced developers, familiarity with Python 3 is beneficial as the course delves into async and parallel programming techniques introduced in Python 3.7 and beyond. Additionally, having Python 3 installed on your system is necessary to follow along with the course exercises.
What projects will I work on during the course?
Throughout the course, you will engage in various exercises that apply async and parallel programming techniques. Key projects include making a producer-consumer application asynchronous, performing async web scraping, and implementing thread-safe banking operations. These projects are designed to reinforce the concepts of concurrency, thread safety, and multiprocessing, allowing you to practice and understand the practical application of the techniques discussed.
Who is the target audience for this course?
This course targets both beginners and experienced Python developers who are interested in enhancing their skills in async and parallel programming. It is suitable for developers looking to improve the performance and scalability of their applications by utilizing modern concurrency techniques in Python. Whether you are a software engineer, data scientist, or a hobbyist programmer, this course will provide valuable insights into leveraging Python's async capabilities.
How does this course compare in depth and scope to other Python courses?
This course uniquely combines foundational concepts like threading and multiprocessing with advanced asynchronous programming techniques introduced in Python 3.7+. It covers not only the core APIs but also best practices for applying them effectively. With 113 lessons, the course offers an extensive exploration of concurrency, including async Flask, thread safety, and C-based parallelism with Cython, providing a more comprehensive understanding compared to many other Python async and parallel programming courses.
What specific tools or platforms will I learn to use?
The course covers a range of tools and platforms essential for async and parallel programming in Python. You will learn to use Python’s asyncio library, work with uvloop for faster asyncio loops, and implement thread safety mechanisms. Additionally, the course explores multiprocessing for maximizing CPU usage and covers async-enabled libraries for tasks like web scraping. These tools will equip you with the skills needed to enhance the performance of your Python applications.
What topics are not covered in this course?
While the course provides a thorough grounding in async and parallel programming in Python, it does not cover topics outside the scope of concurrency and parallelism. This includes areas such as web development frameworks beyond async Flask, machine learning, or deep learning algorithms. The focus remains on core async techniques, thread safety, and multiprocessing, ensuring a deep dive into these specific areas without branching into unrelated programming topics.
What is the expected time commitment for this course?
The course consists of 113 lessons, each designed to build upon the previous ones, with varying lengths. Although the total runtime is not specified, students should expect to dedicate several hours per week to watch the lesson videos, engage with the practical exercises, and review the course materials available on the GitHub repository. The time commitment will vary based on the student's prior experience and familiarity with Python programming concepts.