skillfed

threaded

Decorators for running functions in Thread/ThreadPool/IOLoop

threaded v4.2.0 295.4K downloads/30d#7,923 on PyPI20
Permissive license Apache-2.0 AGING released

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 threaded

uv

uv add threaded

poetry

poetry add threaded

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python Modules

Tags

thread pool decoratorasyncio task decoratorthreading decoratorconcurrent.futures wrapperfunction threadingasync task wrapperthread pool executor decorator
concurrencydecoratorsasyncio

More Python Modules packages