Python Multiprocessing Pool Jump-Start
Run Your Python Functions In Parallel With Just A Few Lines Of Code
How much faster could your python code run (if it used all CPU cores)?
The multiprocessing.Pool class provides easy-to-use process-based concurrency.
This is not some random third-party library, this is a class provided in the Python standard library (already installed on your system).
This is the class you need to use to make your code run faster.
There's just one problem. No one knows about it (or how to use it well).
Introducing: "Python Multiprocessing Pool Jump-Start". A new book designed to teach you multiprocessing pools in Python, super fast!
You will get a fast-paced, 7-part course to get you started and make you awesome at using the multiprocessing pool.
Each of the 7 lessons was carefully designed to teach one critical aspect of the multiprocessing pool, with explanations, code snippets and worked examples.
Each lesson ends with an exercise for you to complete to confirm you understood the topic, a summary of what was learned, and links for further reading if you want to go deeper.
Table of Contents
Lesson 01: Processes and Multiprocessing Pools
- Process-Based Concurrency for Full Parallelism
- Process Pools Provide Reusable Workers
- Discover the Multiprocessing Pool Class
- When to Use the Multiprocessing Pool
Lesson 02: Configure the Multiprocessing Pool
- Configure the Pool via the Constructor
- How to Get the Pool Default Configuration
- How to Configure the Number of Worker Processes
- How to Configure the Worker Process Initialization
- How to Configure the Maximum Tasks Per Worker
- How to Configure the Context Used to Create Workers
Lesson 03: Execute Tasks in Parallel and Wait
- Issue Tasks to the Pool Synchronously (blocking)
- How to Execute One-Off Tasks with apply()
- How to Execute Many Tasks with map()
- How to Execute Many Tasks with Multiple Arguments
Lesson 04: Execute Tasks in Parallel and Not Wait
- Issue Tasks to the Pool Asynchronously (non-blocking)
- How to Issue One-Off Tasks Asynchronously
- How to Issue Many Tasks Asynchronously
- How to Issue Tasks with Multiple Arguments Asynchronously
Lesson 05: Execute Tasks in Parallel and Be More Responsive
- How to Overcome the Limitations of map()
- How to Issue Tasks One-by-One with imap()
- How to Get Results in Task Completion Order
Lesson 06: Callbacks and AsyncResults for Asynchronous Tasks
- How to Configure a Callback Function
- How to Manage Asynchronous Tasks with AsyncResult
- How to Check the Status of Tasks with AsyncResult
- Worked Example of Checking the Status of a Task
Lesson 07: Case Study: Parallel Primality Testing
- How to Perform Primality Testing in Python
- How to Check if Numbers are Prime Sequentially (slow)
- How to Check if Numbers are Prime in Parallel (fast)
Stop copy-pasting code from StackOverflow answers.
Learn Python concurrency correctly, step-by-step.
Learn more about this book here:
How to Buy
- Click the "I want this!" button (in the upper right)
- Choose Credit Card or PayPal and complete the order form then click the "Pay" button.
- You will be redirected to a webpage where you can download your bundle immediately (you will also get an email with the download link, just in case you need it).
About the Author
Jason Brownlee, Ph.D. helps Python developers bring modern concurrency methods to their projects with hands-on tutorials.
Jason loves Python Concurrency. It's all he does. It’s his main thing.
- Read all the books on Python concurrency.
- Used all of the Python concurrency APIs in the standard library.
- Written 500+ tutorials and 12+ books on Python concurrency.
Learn more at SuperFastPython.com
Jason is a software engineer and research scientist with a background in artificial intelligence and high-performance computing. He has authored more than 20 technical books on machine learning and has built, operated, and exited online businesses.
See his linkedin profile here:
- Jason Brownlee on LinkedIn (follow him!)
Hi, Jason here, do you have any questions?
Contact me directly at any time about this product or Python concurrency generally. I'm here to help as best I can.
You can send an email directly to my inbox via:
You'll get a .zip download containing both ebook formats (pdf and epub) and all .py code files.