Python Concurrency with asyncio, Video Edition

Python Concurrency with asyncio, Video Edition

English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 9h 15m | 1.46 GB

Learn how to speed up slow Python code with concurrent programming and the cutting-edge asyncio library.

  • Use coroutines and tasks alongside async/await syntax to run code concurrently
  • Build web APIs and make concurrency web requests with aiohttp
  • Run thousands of SQL queries concurrently
  • Create a map-reduce job that can process gigabytes of data concurrently
  • Use threading with asyncio to mix blocking code with asyncio code

Python is flexible, versatile, and easy to learn. It can also be very slow compared to lower-level languages. Python Concurrency with asyncio teaches you how to boost Python’s performance by applying a variety of concurrency techniques. You’ll learn how the complex-but-powerful asyncio library can achieve concurrency with just a single thread and use asyncio’s APIs to run multiple web requests and database queries simultaneously. The book covers using asyncio with the entire Python concurrency landscape, including multiprocessing and multithreading.

It’s easy to overload standard Python and watch your programs slow to a crawl. Th e asyncio library was built to solve these problems by making it easy to divide and schedule tasks. It seamlessly handles multiple operations concurrently, leading to apps that are lightning fast and scalable.

Python Concurrency with asyncio introduces asynchronous, parallel, and concurrent programming through hands-on Python examples. Hard-to-grok concurrency topics are broken down into simple flowcharts that make it easy to see how your tasks are running. You’ll learn how to overcome the limitations of Python using asyncio to speed up slow web servers and microservices. You’ll even combine asyncio with traditional multiprocessing techniques for huge improvements to performance.

What’s inside

  • Build web APIs and make concurrency web requests with aiohttp
  • Run thousands of SQL queries concurrently
  • Create a map-reduce job that can process gigabytes of data concurrently
  • Use threading with asyncio to mix blocking code with asyncio code
Table of Contents

1 Getting to know asyncio
2 How an event loop works
3 How single-threaded concurrency works
4 Summary
5 Understanding concurrency, parallelism, and multitasking
6 Understanding processes, threads, multithreading, and multiprocessing
7 Understanding the global interpreter lock
8 What is IO-bound and what is CPU-bound
9 Accessing and manually managing the event loop
10 Canceling tasks and setting timeouts
11 Introducing long-running coroutines with sleep
12 Measuring coroutine execution time with decorators
13 Running concurrently with tasks
14 Summary
15 Tasks, coroutines, futures, and awaitables
16 The pitfalls of coroutines and tasks
17 Using debug mode
18 asyncio basics
19 A first asyncio application
20 An echo server on the asyncio event loop
21 Connecting to a server with Telnet
22 Shutting down gracefully
23 Summary
24 Using the selectors module to build a socket event loop
25 Working with non-blocking sockets
26 Asynchronous context managers
27 Concurrent web requests
28 Finer-grained control with wait
29 Processing requests as they complete
30 Running requests concurrently with gather
31 Running tasks concurrently, revisited
32 Summary
33 Asynchronous generators and streaming result sets
34 Connecting to a Postgres database
35 Defining a database schema
36 Executing queries concurrently with connection pools
37 Executing queries with asyncpg
38 Managing transactions with asyncpg
39 Non-blocking database drivers
40 Summary
41 Handling CPU-bound work
42 Multiple processes, multiple event loops
43 Shared data and locks
44 Solving a problem with MapReduce using asyncio
45 Summary
46 Using process pool executors with asyncio
47 Using process pools
48 Event loops in separate threads
49 Handling blockingwork with threads
50 Locks, shared data, and deadlocks
51 Summary
52 Using threads for CPU-bound work
53 Using threads with asyncio
54 Creating a chat server and client
55 Creating servers
56 Non-blocking command-line input
57 Stream readers and stream writers
58 Streams
59 Summary
60 Transports and protocols
61 ASGI with Starlette
62 Django asynchronous views
63 Summary
64 The asynchronous server gateway interface
65 Web applications
66 Implementing the product listing API
67 Introducing the backend-for-frontend pattern
68 Microservices
69 Summary
70 Conditions
71 Limiting concurrency with semaphores
72 Locks
73 Notifying tasks with events
74 Summary
75 Synchronization
76 Asynchronous queues
77 LIFO queues
78 Priority queues
79 Summary
80 Communicating with subprocesses
81 Managing subprocesses
82 Summary
83 Advanced asyncio
84 Context variables
85 Creating a custom event loop
86 Forcing an event loop iteration
87 Summary
88 Using different event loop implementations

Homepage