concurrent.futures runs callables on thread or process pools behind one Executor API
Answer: ThreadPoolExecutor uses a pool of threads and ProcessPoolExecutor uses a pool of processes to execute calls asynchronously. Both are Executor subclasses with submit() and map().
Example
from concurrent.futures import ThreadPoolExecutor, as_completed
import shutil
with ThreadPoolExecutor(max_workers=4) as e:
futs = [e.submit(shutil.copy, f"src{i}.txt", f"dest{i}.txt") for i in range(4)]
for f in as_completed(futs):
f.result()
Facts
ThreadPoolExecutoris an Executor subclass that uses a pool of threads to execute calls asynchronously.ProcessPoolExecutoruses a pool of processes. Itsmax_workersdefaults toos.process_cpu_count()when None or not given.- Using the executor as a context manager via the
withstatement will shutdown the Executor, as ifshutdown()were called with wait set to True. Executor.mapis likemap(fn, *iterables), but it collects the iterables immediately rather than lazily unless abuffersizeis specified.- Deadlocks can occur when a callable waits on the result of another Future, for example
future.result()inside a single-worker pool. - The
cancel_futuresparameter ofshutdown()was added in 3.9.
Origin
PEP 3148 proposed this package to facilitate the evaluation of callables using threads and processes; it shipped in Python 3.2.
See also
Claims
- id: C1 claim: ThreadPoolExecutor uses a pool of threads. source: S1 evidence: "ThreadPoolExecutor is an Executor subclass that uses a pool of threads to execute calls asynchronously."
- id: C2 claim: ProcessPoolExecutor defaults to os.process_cpu_count() workers. source: S1 evidence: "If max_workers is None or not given, it will default to os.process_cpu_count()"
- id: C3 claim: Executor.map collects iterables immediately unless buffersize is set. source: S1 evidence: "The iterables are collected immediately rather than lazily"
- id: C4 claim: PEP 3148 designed a package for callables on threads and processes. source: S2 evidence: "facilitates the evaluation of callables using threads and processes"
Sources
- [S1] concurrent.futures — Launching parallel tasks. Python docs (library). https://docs.python.org/3/library/concurrent.futures.html . License: PSF-2.0. Accessed 2026-11-18.
- [S2] PEP 3148 – futures - execute computations asynchronously. Python PEPs. https://peps.python.org/pep-3148/ . License: Public-Domain. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python docs (library), concurrent.futures — Launching parallel tasks; Python PEPs, PEP 3148 – futures - execute computations asynchronously. PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Public-Domain (https://peps.python.org/pep-0001/). PEP text is placed in the public domain (some also CC0-1.0). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python docs (library), concurrent.futures — Launching parallel tasks; Python PEPs, PEP 3148 – futures - execute computations asynchronously. PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Public-Domain (https://peps.python.org/pep-0001/). PEP text is placed in the public domain (some also CC0-1.0).
Cite this
iinventedlight. 2026. "concurrent.futures runs callables on thread or process pools behind one Executor API." iinventedlight Library, iil:note:yhpkhg46, version of 2026-11-18. https://iinventedlight.com/library/notes/python-concurrent-futures/. License: CC-BY-4.0.
@misc{iil_note_yhpkhg46,
author = {{iinventedlight}},
title = {{concurrent.futures runs callables on thread or process pools behind one Executor API}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/python-concurrent-futures/},
note = {Permanent ID iil:note:yhpkhg46. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- python-concurrent-futures.table.json (table; CC-BY-4.0)
- python-concurrent-futures.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-concurrent-futures.md.