threaded
Decorators for running functions in Thread/ThreadPool/IOLoop
What it is and what it does
threaded is a decorator library that wraps ordinary Python functions to run them concurrently using standard library primitives—ThreadPoolExecutor, threading.Thread, or asyncio.Task. Instead of writing boilerplate like `loop.create_task()` or `thread_pool.submit()` every time you want to run a function concurrently, you decorate it once and call it normally; the decorator handles the concurrency setup and returns a future or thread object. It supports Python 3.8 through 3.12 on CPython and PyPy, with no external dependencies beyond the standard library.
The library provides three main decorators: ThreadPooled (submits to a thread pool with configurable worker count), Threaded (wraps in a threading.Thread with optional daemon and auto-start modes), and AsyncIOTask (wraps in an asyncio.Task). Each decorator can be configured with custom event loops or loop-extraction logic for integration with existing async code. The thread pool can be shut down explicitly during application shutdown.
Use it for:
- Offload blocking I/O operations (file reads, network calls) to a thread pool without writing submit/future boilerplate
- Launch long-running background tasks as daemon threads with a single decorator instead of manual Thread instantiation
- Wrap synchronous functions to run as asyncio tasks within an event loop for mixed sync/async codebases
- Reduce copy-paste of concurrent.futures or threading setup code across a codebase by standardizing on decorators
- Integrate blocking library calls into async code by scheduling them on a thread pool executor
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides decorators to wrap functions for execution in thread pools, individual threads, or asyncio tasks, eliminating boilerplate code for common concurrency patterns.
Yes, if you frequently write concurrent code and want to reduce boilerplate. The package is stable (Production/Stable classifier), has no dependencies, and works across modern Python versions. The aging maintenance status (last release 996 days ago) is not a blocker for a mature decorator library, but means you should not expect rapid bug fixes or new features. No known vulnerabilities.
Install
threaded on PyPI
pip
pip install threadeduv
uv add threadedpoetry
poetry add threadedInstalling threaded
Before you install
Low install friction with no runtime dependencies. Maintenance is aging—last release was 996 days ago—but the repository remains active with a recent commit on 2026-01-12, suggesting occasional updates rather than abandonment.
License in practice
Licensed under Apache-2.0 (permissive), allowing commercial and private use with minimal restrictions; suitable for most projects without license compatibility concerns.
Quickstart
pip install threaded
import threaded
@threaded.ThreadPooled
def blocking_task():
return "result"
future = blocking_task()
import concurrent.futures
concurrent.futures.wait([future])
Requires Python 3.8 or later; asyncio integration requires an active event loop when using AsyncIOTask or ThreadPooled with loop_getter.
Verify before relying
- Whether the package handles thread-local storage or context propagation correctly in all use cases
- Performance characteristics when managing large numbers of concurrent tasks relative to raw threading APIs
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.8.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 996 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 295,355/month — #7,923 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: threaded-4.2.0-py3-none-any.whl
Keywords: pooling, multithreading, threading, asyncio, development
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
aioprocessingProvides asyncio-compatible wrappers around…
permissive · top 15,000 on PyPI
unsyncDecorator-based library that runs async…
permissive · top 15,000 on PyPI
kthreadKThread provides a way to forcefully terminate…
permissive · top 15,000 on PyPI
pypelnPypeln lets you build concurrent data pipelines…
permissive · top 15,000 on PyPI
snapshot-restore-pyRegisters runtime hooks in AWS Lambda…
permissive · top 5,000 on PyPI
multitaskingConverts Python methods into non-blocking,…
permissive · top 1,000 on PyPI
PebblePebble provides decorators and pool…
copyleft · top 5,000 on PyPI
func-timeoutRuns any Python function with a specified…
copyleft · top 5,000 on PyPI
janusProvides a thread-safe queue with both…
permissive · top 5,000 on PyPI
requests-futuresWraps the requests library to execute HTTP…
permissive · top 5,000 on PyPI