Install & Compatibility
Where this runs
tested against v3.0.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.036s · 19.3MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.4s · import 0.032s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ThreadPoolExecutor
✓ from concurrent.futures import ThreadPoolExecutor
ProcessPoolExecutor
✓ from concurrent.futures import ProcessPoolExecutor
Future
✓ from concurrent.futures import Future
✗ import futures
The top-level 'futures' package is an internal implementation detail; direct import of `concurrent.futures` is the correct pattern.
Demonstrates basic usage of `ThreadPoolExecutor` to run two simple tasks concurrently and retrieve their results. The `with` statement ensures proper shutdown of the executor. This code is designed for Python 2.
import time
from concurrent.futures import ThreadPoolExecutor
def my_task(name):
print "Starting task %s" % name # Python 2 print statement
time.sleep(1) # Simulate work
print "Finished task %s" % name # Python 2 print statement
return "Result from %s" % name
if __name__ == '__main__':
# Create a thread pool with 2 workers
with ThreadPoolExecutor(max_workers=2) as executor:
# Submit tasks
future1 = executor.submit(my_task, "Alpha")
future2 = executor.submit(my_task, "Beta")
# Get results (blocks until complete)
print future1.result()
print future2.result()
print "All concurrent tasks completed." # Python 2 print statement
Debug
Known issues
breakingThis library is a backport specifically for Python 2.6/2.7. It is *not* compatible with Python 3, where `concurrent.futures` is part of the standard library. Attempting to install or use this package on Python 3 will lead to syntax errors or other runtime issues.affects: All versions of `futures` on Python 3
gotchaThe `ProcessPoolExecutor` class in this Python 2 backport has known, unfixable problems and should not be relied upon for mission-critical work. Consider `ThreadPoolExecutor` for I/O-bound tasks or alternative multiprocessing solutions for CPU-bound tasks.affects: All versions
gotchaExceptions raised within tasks submitted to an executor are stored in the `Future` object, not immediately re-raised. They will only be re-raised when `future.result()` is called or when iterating over results from `executor.map()` or `as_completed()`. If `future.result()` is never called for a future that failed, the exception may be silently ignored.affects: All versions
gotchaWhen using `ThreadPoolExecutor`, be cautious of deadlocks if tasks wait on the results of other tasks submitted to the *same* executor, especially if the pool size (`max_workers`) is insufficient to prevent all workers from becoming blocked simultaneously.fixEnsure `max_workers` is sufficiently large or avoid circular dependencies between tasks within the same executor.
affects: All versions
Upgrade
Version history
3.4.0latest on PyPI · released Oct 31, 2022
Audit
Dependencies
No dependency data recorded yet.