leasepool documentation¶
leasepool is a local executor orchestration library for async Python applications.
It helps async services safely borrow execution capacity from
ThreadPoolExecutor and ProcessPoolExecutor backends using leases,
backpressure, expiry, adaptive sizing, batch submission, and clean shutdown.
Project links¶
Free-threaded Python / no-GIL support¶
leasepool is a pure Python package and does not ship native extension
modules. It is intended to work on CPython free-threaded builds.
Current support level: Stable.
The package declares:
Programming Language :: Python :: Free Threading :: 3 - Stable
User-submitted functions are still responsible for their own thread-safety when executed concurrently.
Python 3.11+ support includes:
threadbackend for blocking I/O and legacy synchronous SDKs.processbackend for CPU-heavy Python work.interpreterbackend reserved for Python 3.14+InterpreterPoolExecutor.
Warning
leasepool is not a distributed task queue. It is not a replacement for
Celery, Dramatiq, RQ, Ray, or a message broker. It manages local executor
capacity inside one Python process.
User guide
- Installation
- Quickstart
- Core concepts
- Configuration
- Thread backend
- Process backend
- Process log forwarding
- WorkGrinder
- Adaptive sizing
- Error handling
- FastAPI pattern
- Examples
- FAQ
- Is leasepool a task queue?
- Should I use threads or processes?
- Can I submit async functions?
- Is max_pools global?
- What happens if every pool is leased?
- What happens after a lease expires?
- Can I use InterpreterPoolExecutor on Python 3.11?
- Why do worker-process logs not appear in my app logs?
- Can I pass executor-specific options?
- What happens if I release a lease while submitted work is still running?
- Does lease expiry kill already-running work?
- Can I call WorkGrinder from another event loop?
API reference