Meet Threads and Processes
Intuitive Python — by David Muller (24 / 41)
👈 Approach Concurrency with Caution | TOC | Using concurrent.futures to Run Code Concurren tly 👉
Python provides two keystone standard library modules that allow you to run code concurrently:
- threading
- multiprocessing
The threading module provides the Thread object for running code with threads and the multiprocessing module provides the Process object for running code with processes.
What Are Threads and Processes?
INFORMATION
Threads and processes are abstractions provided by your operating system that allow you to run code. In general, processes are independent sequences of execution with their own dedicated memory space. Threads, by contrast, live within a process. One or more threads can run within a given parent process. Threads share memory with each other and the parent process.
The following table summarizes some of the key differences between threads and processes in Python:
In later sections, we’ll discuss the last two columns: memory sharing and the effects of…