Concurrent Execution
threading — Thread-based parallelism
Source code: Lib/threading.py
_thread — Low-level threading API
This module provides low-level primitives for working with multiple threads (also called light-weight processes or tasks) — multiple threads of control sharing their global data space. For synchronization, simple locks (also called mutexes or binary semaphores) are provided. The
module provides an easier to use and higher-level threading API built on top of this module.
threading
contextvars — Context Variables
This module provides APIs to manage, store, and access context-local state. The
class is used to declare and work with Context Variables. The ContextVar
function and the copy_context()
class should be used to manage the current context in asynchronous frameworks.
Context
sched — Event scheduler
Source code: Lib/sched.py
subprocess — Subprocess management
Source code: Lib/subprocess.py
concurrent.futures — Launching parallel tasks
Source code: Lib/concurrent/futures/thread.py
and Lib/concurrent/futures/process.py
The concurrent package
Currently, there is only one module in this package:
multiprocessing.shared_memory — Provides shared memory for direct access across processes
Source code: Lib/multiprocessing/shared_memory.py
multiprocessing — Process-based parallelism
Source code: Lib/multiprocessing/
queue — A synchronized queue class
Source code: Lib/queue.py