
Join a beginner-friendly introduction to asynchronous programming with Python, in the Asynchronous Python for beginners course, led by Emmanuela Powell, who shares a decade of experience and practical use cases.
Explanation of the course benefits and why you should take it
Explore asynchronous Python fundamentals, including asynchronous programming models, monkey patching, event loop, async/await, routines, tasks, and futures, with hands-on demos from a GitHub repository.
clone the async io dash examples repo from cavey on github and set up a workspace with python 3 and poetry to create a virtual environment and run three examples.
Gain an understanding of how clients and servers interact in Synchronous scenarios
Gain an understanding of how clients and servers interact in Asynchronous scenarios
Explains the WSGI specification, a Python interface between applications and web servers, where a callable accepts a request and a start_response function and streams an iterable response after calling start_response.
Explore a basic WSGI Flask application demo running on localhost:9000, demonstrating single-threaded and multithreaded modes, printing the request and headers, and returning a hello world response.
Demonstrate how a WSGI blocking application shows how a single request can block health checks due to the Python interpreter lock, using sleep and a threading lock.
Explore techniques to resolve blocking in asynchronous Python, such as monkey patching, to keep microservice pipelines responsive and prevent health check timeouts and data loss.
Master monkey patching to alter runtime behavior without changing source code, swapping blocking functions with non-blocking patches, such as patching a socket in the request library to avoid blocking.
Explore monkey patching to remove blocking in the request library by patching the socket, compare synchronous and asynchronous patterns using threading and events, and observe dramatic concurrency gains.
Explore how Python's event loop coordinates asynchronous tasks and callbacks, contrast threads with coroutines, and show how async/await enables this within a Python server framework.
ASGI, short polling, long polling, and websockets
Explore an ASGI demo with a basic event loop in the unicorn framework. Define an async app that handles scope, receive, and send, and demonstrates chunked responses.
Asyncio Theory & definitions
Asyncio Coroutine Demo
Asyncio Tasks Demo
Explore futures theory in asynchronous python, showing how process pool and thread pool executors run non-async functions concurrently with async io, handling blocking actions like time.sleep and network requests.
This futures demo contrasts thread pool and process pool execution of blocking code, highlighting deadlocks from shared state and showing how processes avoid them, and debugging async io code.
Learn how to implement a WebSocket with async IO to push server time to multiple clients, maintaining a continuous two-way connection and comparing it to long polling.
Explore an asynchronous Python WebSocket demo that synchronizes a live counter and online user count across multiple clients, using a server-driven JSON payload and async IO.
Explore asyncio debug mode to reveal when the event loop is blocked, and learn three ways to enable debugging: environment variable, asyncio.run flag, and loop.set_debug.
Explore asyncio debugging techniques by enabling the debug logger, detect never awaited coroutines, and diagnose event loop blocking using tests, stack traces, and concurrent task demos.
This course will allow students to explore the principles of Asynchronous programming with Python. By setting a foundation of the problem sets async python can help solve and diving into the frameworks that facilitate this. Your education will be further enhanced by walking through coding exercises and demos that aim to provide sample scenarios.
Instructor:
Emmanuel Apau, an AWS Certified DevOps specialist with 10 years of experience developing innovative automation solutions using DevOps & Site reliability best practices for clients with Python
Topics Covered:
1. Synchronous vs Asynchronous Programming
2. WSGI vs ASGI Applications
3. Monkey Patching
4. The event loop
5. Asyncio
6. Coroutines, Tasks & Futures
7. Websockets
Once this course is complete:
- You will be able to build scalable python web apps that handle thousands of web requests.
- You will be able to implement WebSockets, to build dynamic web applications.
- You will be able to identify blocking code and create solutions for it.
- You will utilize 2-way communication between the client and understand the scenarios when it is necessary.
- You will have a complete understanding of Asyncio and its features
Prerequisites:
- This course expects that you have a basic understanding of python development.
- That is you know how to install dependencies, execute python scripts
- That you are familiar with web development frameworks