6 Handling CPU-bound work
This chapter covers
- The multiprocessing library
- Creating process pools to handle CPU-bound work
- Using
async
andawait
to manage CPU-bound work - Using MapReduce to solve a CPU-intensive problem with asyncio
- Handling shared data between multiple processes with locks
- Improving the performance of work with both CPU- and I/O-bound operations
Until now, we’ve been focused on performance gains we can get with asyncio when running I/O-bound work concurrently. Running I/O-bound work is asyncio’s bread and butter, and with the way we’ve written code so far, we need to be careful not to run any CPU-bound code in our coroutines. This seems like it severely limits asyncio, but the library is more versatile than just handling I/O-bound ...
Get Python Concurrency with asyncio now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.