In this course, we will look at using asynchronous programming in Python: the options, pitfalls, and best practices. We start with multi-threading, which is particularly useful when there is a lot of waiting, e.g. for HTTP requests or disk access. With multi-threading, you can start many requests in quick succession and then wait for all of them to complete at once. Next, the course will show you how to write your code in a thread-safe manner, and how to use it risk-free. Further, it covers Python’s global interpreter lock, which prevents a lot of serious problems in Python but also stops you from running threads in parallel.
Going forward we discover how you can use Python’s multiprocessing library to run functions in parallel. Threads and processes often need to share or exchange data. In asynchronous code just passing Python objects is usually not the safest way to do this. This course looks at the main ways to do this correctly in Python, such as queues and events. Finally, the course moves on to the concurrent.future library which contains higher-level abstractions, including thread and processing pools and an asynchronous map function.
The course finishes with advice on how to write robust asynchronous code, and how to test and debug it.
What You Will Learn
- Take advantage of multi threading (concurrency) using the threading module
- Implement multi processing (parallelism) using the multiprocessing module
- Understand inter-process communication and data sharing using locks, queues, semaphores, barriers, events, and timers
- Test and debug asynchronous Python code
- Understand thread and process pools using concurrent.futures
- Who This Video Is For
- Intermediate to experienced Python programmers who want to speed up existing Python code by using multi processing and multi threading.