Python Threading Jump-Start
Python Threading Jump-Start
Develop Concurrent IO-bound Programs And Work With The GIL
Unlock concurrency with Python threads (and run 100s or 1,000s of tasks simultaneously)
The threading module provides easy-to-use thread-based concurrency in Python.
Unlike Python multiprocessing, the threading module is limited by the infamous Global Interpreter Lock (GIL).
Critically, the GIL is released when performing blocking I/O. Additionally, threads can share memory making them perfectly suited to I/O-bound tasks such as reading and writing from files and socket connections.
This is the API you need to use to make your code run faster.
Introducing: "Python Threading Jump-Start". A new book designed to teach you the threading module in Python, super fast!
You will get a rapid-paced, 7-part course to get you started and make you awesome at using the threading API.
Each of the 7 lessons was carefully designed to teach one critical aspect of the threading module, with explanations, code snippets, and worked examples.
You will discover:
- How to choose tasks that are well suited to threads.
- How to create and run new threads.
- How to locate and query running threads.
- How to use locks, semaphores, barriers and more.
- How to share data between threads using queues.
- How to execute ad hoc tasks with reusable worker threads.
- How to gracefully stop and forcefully kill threads.
Each lesson ends with an exercise for you to complete to confirm you understand the topic, a summary of what was learned, and links for further reading if you want to go deeper.
Table of Contents
-
Lesson 01: Thread-Based Concurrency
- Python Concurrency
- What is Threading in Python
- What is the Global Interpreter Lock
- What is Multiprocessing in Python
- When to Use Threads
- Why Not Always Use Multiprocessing
-
Lesson 02: Create and Start New Threads
- Main Thread, Helper Thread, and New Threads
- Life-Cycle of a Thread
- How to Run a Function in a New Thread
- How to Extend the Thread Class
- Thread-Local Storage
-
Lesson 03: Configuring and Interacting with Threads
- How to Configure New Threads
- How to Query the Status of a Thread
- How to Get the Current, Main, and All Thread
- ho two Handle Unexpected Exceptions in New Threads
-
Lesson 04: Synchronize and Coordinate Threads
- How to Protect Critical Section with a Mutex Lock
- How to Limit Access to a Resource with a Semaphore
- How to Signal Between Threads Using an Event
- How to Coordinate Using a Condition Variable
- How to Coordinate Thread with a Barrier
-
Lesson 05: Share Data Between Threads
- Share Data Using Global Variables
- Return Values From Threads via Instance Variables
- Share Data Between Threads with Queues
-
Lesson 06: Run Tasks with Reusable Workers in Thread Pools
- What Are Thread Pool
- How to Use Thread Pools in Python
- How to Configure the ThreadPool Class
- How to Execute Tasks Synchronously and Asynchronously
- How to Use Callbacks to Handle Results and Errors
- How to Interact With Asynchronous Tasks
-
Lesson 07: Close, Stop, and Kill Threads
- Alternatives to Stopping a Thread
- How a Thread Can Close Itself
- How to Gracefully Stop a Thread
- How to Forcefully Kill a Thread
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.
Jason has:
- 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!)
Any Questions?
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.