A small add-on for the Requests library that returns futures from session calls so multiple HTTP requests can run concurrently via concurrent.futures.
Overview
Requests Futures is a minimal extension to the Python Requests HTTP library that uses the standard library concurrent.futures module. It requires Python 3.10 or newer and keeps the familiar Session API, except calls return Future objects instead of blocking until each Response is ready.
You obtain responses by calling result on each future, and exceptions surface at result time rather than at submit time. By default a ThreadPoolExecutor with eight workers backs the session, sharing one Requests Session across worker threads; the documentation warns that Session is not thread-safe for concurrent mutation of cookies or headers.
The library supports attaching metadata to futures, using as_completed to process finished requests, and using the session as a context manager to cancel queued work on exit. A ProcessPoolExecutor can be supplied for isolation when per-request memory is high, with pickling constraints documented for session subclasses.
Additional documentation covers timeouts, retries through mounted HTTPAdapter and urllib3 Retry, connection pool sizing, streaming caveats, shared executors, hooks, context propagation, and OpenTelemetry. Install via pip install requests-futures.
Key features
- FuturesSession wraps Requests Session
- ThreadPoolExecutor default eight workers
- Optional ProcessPoolExecutor
- Context manager cancels queued futures
- Preserves Session method signatures
- Documented thread-safety guidance
Use cases
- Parallel HTTP fetches with Requests
- Overlapping I/O-bound API calls
- Cleaning up unfinished background requests