Talk Python: Async Techniques and Examples
Michael Kennedy
  • Course duration: 4h 59m
Talk Python: Async Techniques and Examples is the first liveVideo course in the exciting Talk Python series from podcaster and software trainer Michael Kennedy. In this hands-on and visuals-first video, you’ll learn the entire spectrum of Python's parallel programming APIs. You’ll get started with the new and powerful async and await keywords of Python 3.5+, as well as the underpinning module: asyncio. Then you’ll cover Python's threads for parallelizing older operations and multiprocessing for CPU bound operations. You'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.


Distributed by Manning Publications

This course was created independently by Python expert Michael Kennedy and is distributed by Manning through our exclusive liveVideo platform.

About the subject

Asynchronous Python code runs faster, scales better, and can take advantage of modern, multicore CPUs. To get the performance benefits of parallelism, you’ll need to overhaul the way you write your programs, and this course will show you exactly how.

About the video

Talk Python: Async Techniques and Examples is a comprehensive course on parallel programming in Python. It covers tried and true foundational concepts such as threads and multiprocessing, as well as modern async features based on Python 3.7+ with async and await. In addition to the core concepts and APIs for concurrent programming, you’ll learn best practices for concurrency, how to choose between the various APIs, and how to use APIs together for the biggest advantage. All concepts are backed up by clear and precise visuals, and you’ll get the chance to code along and explore detailed code samples for each new parallel technique.
Table of Contents detailed table of contents

Welcome to the course

Course introduction

Async for taking full advantage of modern CPUs

Topics covered

Student prerequisites

Meet your instructor

Setup and following along

Do you have Python 3?

Getting Python 3

Recommended text editor

Hardware requirements

Get the source code

Why async?

Async for computational speed

Demo: Why you need async for speed

An upper bound for async speed improvement

Async for scalability

Concept: Visualizing a synchronous request

Concept: Visualizing an asynchronous request

Python’s async landscape

Why threads don’t perform in Python

async and await with asyncio

Python async landscape: asyncio

I/O-driven concurrency

Demo: Understanding basic generators

Demo: The producer-consumer app

Demo: Make the producer-consumer async

Demo: Make the producer-consumer async (methods)

Concept: asyncio

Performance improvements of producer consumer with asyncio

Faster asyncio loops with uvloop

Let’s do some real work

Synchronous web scraping

Async web scraping

Concept: async web scraping

Other async-enabled libraries

Threads

Python async landscape: Threads

Visual of thread execution

How to choose between asyncio and threads

Demo: hello threads

Demo: Waiting on more than one thread

Demo: Something productive with threads

Concept: Thread API

Concept: Tips for multiple threads

Cancelling threads with user input

Concept: Timeouts

Demo: Attempting to leverage multiple cores with threads

Thread safety

Python async landscape: Thread Safety landscape

Threads are dangerous

Visualizing the need for thread safety

Demo: An unsafe bank

Demo: Make the bank safe (global)

Demo: A missed lock in our bank (global)

Demo: Make the bank safe (fine-grained)

Demo: Breaking a deadlock

Concept: Basic thread safety

Leveraging CPU cores with multiprocessing

Python async landscape: multiprocessing

Introduction to scaling CPU-bound operations

Demo: Scaling CPU-bound operations with multiprocessing

Concept: Scaling CPU-bound operations

Multiprocessing return values

Concept: Return values

Common APIs with execution pools

Python async landscape: Execution pools

Demo: Executor app introduction

Demo: Executor app (threaded-edition)

Demo: Executor app (process-edition)

Concept: Execution pools

Built on asyncio

Python async landscape: asyncio derivatives

Why do we need more libraries?

Introducing unsync

Demo: unsync app introduction

Demo: unsync app for mixed-mode parallelism

Concept: Mixed-mode parallelism with unsync

Introducing Trio

Demo: Starter code for Trio app

Demo: Converting from asyncio to Trio

Demo: Cancellation with Trio

Concept: Trio nurseries

The trio-async package

Asyncio-based web frameworks

Python async landscape: Async web

Review: Request latency again

Demo: Introducing our Flask API

There is no async support for Flask

Demo: Introducing Quart for async Flask

Demo: Converting from Flask to Quart

Demo: Making our API async

Demo: An async weather endpoint

Concept: Flask to Quart

Load testing web apps with wrk

A note about rate limiting with external services

Performance results

Remember to run on an ASGI server

Parallelism in C with Cython

Python async landscape: Cython

C and Python are friends

Why Cython

Cython syntax compared

Demo: Hello Cython

Concept: Getting started with Cython

Demo: Fast threading with Cython (app review)

Demo: Fast threading with Cython (hotspot)

Demo: Fast threading with Cython (conversion)

Demo: Fast threading with Cython (GIL-less)

Demo: Fast threading with Cython (int overflow issues)

Concept: Cython’s nogil

Course conclusion and review

The finish line

Review: Why async?

Review: asyncio

Review: Threads

Review: Thread safety

Review: multiprocessing

Review: Execution pools

Review: Mixed-mode parallelism

Review: Coordination with Trio

Review: Async Flask

Review: Cython

Thanks and goodbye

Prerequisites

For intermediate Python programmers.

What you will learn

  • How concurrency improves performance and scalability
  • Build async-capable code with the new async and await keywords
  • Add asynchrony to your app
  • Work with multiple threads to run CPU-bound work in Python
  • Use locks and thread safety mechanisms to protect shared data
  • Take full advantage of multicore CPUs with multiprocessing
  • Add massive speedups with Cython to circumvent Python’s GIL
  • Create async view methods in Flask web apps

About the instructor

Michael Kennedy is the host of the #1 Python podcast, Talk Python to Me. He’s interviewed many of the leaders and creators in the Python community and brings that perspective to all the courses he creates. He has been a professional software trainer for over 10 years.

placing your order...

Don't refresh or navigate away from the page.
liveVideo $49.00
Talk Python: Async Techniques and Examples (liveVideo) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.