Python ThreadPoolExecutor Jump-Start
Execute IO-Bound Tasks Asynchronously With Modern Thread Pools
How much faster could your Python code run (if you used 100s of thread workers)?
The ThreadPoolExecutor class provides modern thread pools for IO-bound tasks.
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 make your code run faster.
There's just one problem. No one knows about it (or how to use it well).
Introducing: "Python ThreadPoolExecutor Jump-Start". A new book designed to teach you thread pools in Python, super fast!
You will get a rapid-paced, 7-part course to get you started and make you awesome at using the ThreadPoolExecutor.
- How to create thread pools and when to use them.
- How to configure thread pools including the number of threads.
- How to execute tasks with worker threads and handle for results.
- How to execute tasks in the thread pool asynchronously.
- How to query and get results from handles on asynchronous tasks called futures.
- How to wait on and manage diverse collections of asynchronous tasks.
- How to develop a concurrent website status checker that is 5x faster than the sequential version.
Each of the 7 lessons was carefully designed to teach one critical aspect of the ThreadPoolExecutor, 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: Threads, Executors, and Thread Pools
- What is Thread-Based Concurrency
- Thread Pools Provide Reusable Workers
- ThreadPoolExecutor for Python Thread Pools
- Welcome to the ThreadPoolExecutor Class
- When to Use the ThreadPoolExecutor
Lesson 02: Configure the ThreadPoolExecutor
- How to Configure the ThreadPoolExecutor
- How to Inspect the Default Configuration
- How to Configure the Number of Worker Threads
- How to Configure the Worker Thread Names
- How to Configure Worker Thread Initialization
Lesson 03: Execute Multiple Tasks Concurrently
- What is the map() Method
- How to Execute Tasks with One Argument
- How to Execute Tasks with Multiple Arguments
- How to Execute Tasks with No Return Values
- How to Execute Tasks with a Timeout
Lesson 04: Execute One-Off Tasks Asynchronously
- What is the submit() Method
- How to Execute a Task with One Argument
- How to Execute a Task with Multiple Arguments
- How to Execute a Task with No Arguments
- How to Execute a Task with No Return Value
- How to Execute Many One-Off Tasks
Lesson 05: Query Asynchronous Tasks
- What are Future Objects
- How to Check the Status of Future Objects
- How to Get Results From Future Objects
- How to Cancel Future Objects
- How to Add Callbacks to Future Objects
- How to Get Exceptions From Future Objects
Lesson 06: Manage Collections of Asynchronous Tasks
- What are the Module Functions
- How to Handle Results as Tasks Finish
- How to Wait for All Tasks
- How to Wait for the First Task
- How to Wait for First Task Failure
Lesson 07: Case Study Checking the Status of Websites
- How to Check Website Status One-by-One (slow)
- How to Check Website Status Concurrently (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: