Meet Threads and Processes

Intuitive Python — by David Muller (24 / 41)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 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:

  1. threading
  2. 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…

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.