kuu
a native distributed task queue for python
uv add kuu
# extras: dashboard, nats, postgres, prometheus, redis
quick start
# myapp/app.py
from kuu import Kuu
from kuu.brokers.redis import RedisBroker
from kuu.results.redis import RedisResults
app = Kuu(broker=RedisBroker(url=...), results=RedisResults(url=...))
# myapp/tasks.py
from typing import TypedDict
from datetime import timedelta
from .app import app
class ChargeResult(TypedDict):
ok: bool
charged: int
@app.task
async def charge(user_id: int, amount_cents: int) -> ChargeResult:
return {"ok": True, "charged": amount_cents}
@app.sched(every(hours=4, starting=time(hours=1, minutes=30))) # 1:30, 5:30, 9:30...
async def refresh_balance() -> None: ...
# myapp/main.py
from .tasks import charge
async def run() -> None:
# type checker infers TaskHandle[ChargeResult]
# args/kwargs of the task remain typed
handle = await charge.q(user_id=1, amount_cents=500)
# type checker infers ChargeResult
result = await handle.result(timeout=30)
# reads ./kuunfig.toml or [tool.kuu] in ./pyproject.toml
# starts control plane with all presets spawned
uv run kuu start
# singular preset with dashboard / remote uplink
uv run kuu start --preset ...
what's inside
- brokers: Redis Streams, NATS JetStream, in-memory (for tests)
- scheduler: interval jobs (
@app.every) and composable cron-like schedules (@app.sched) - middleware: logging, retry with exponential backoff + jitter, timeout, plus custom hooks
- events: pub/sub signals for task lifecycle (
task_enqueued..task_dead) - serialization: JSON (msgspec), Msgpack, Pickle, with extensible type coercion via
marshal - persistence: SQLite (zero-config) and PostgreSQL backends for run/log history
- dashboard: Starlette+HTMX web UI with live worker/queue stats and task management
- prometheus: multiprocess metrics with worker-side emitter and client-side middleware
- hot reload: watch filesystem changes, restart worker pool on settled batches
config
put the block below into kuunfig.toml, or under [tool.kuu] in your pyproject.toml
[default] holds base values; each [presets.<name>] overrides only the fields you set.
unset fields fall back to [default]. a flat config (no [default] wrapper) still works
[default]
queues = [] # consume from; empty = auto-discover from registry
processes = 1 # worker subprocesses to spawn
concurrency = 64 # max concurrent tasks per worker
prefetch = 16 # batch size; defaults to max(1, concurrency // 4)
shutdown_timeout = 30.0 # seconds to wait for in-flight tasks on stop
[default.metrics]
enable = false
host = "0.0.0.0"
port = 9191
[default.dashboard]
enable = false
host = "0.0.0.0"
port = 8181
path = "/dashboard"
scheduler.enable = false # run scheduler loop in-process; jobs declared via app.every / app.sched
[default.watch]
enable = false # reload workers on filesystem changes
root = "." # path to watch
respect_gitignore = true # skip files matched by .gitignore
exclude = [".git/**"] # extra globs to exclude
reload_delay = 0.25
reload_debounce = 0.5
[default.persistence]
enable = true # store run/log history
dsn = "sqlite:///./kuu.db" # sqlite (default) or postgres://...;
# also can be provided via KUU_PERSISTENCE_DSN env var
schema = "" # postgres schema; empty = default
runs_table = "kuu_runs" # Attempt rows
logical_runs_table = "kuu_logical_runs" # parent Runs
logs_table = "kuu_run_logs"
keep_days = 7 # auto-purge runs older than this
max_runs = 100_000 # hard cap on stored runs
log_level = "INFO"
capture_args = false # sensitive inputs are opt-in
capture_headers = false
capture_result = false
attempt_observation_bytes = 10_485_760 # per-Attempt budget; overflow becomes a gap
[presets.prod]
processes = 8
concurrency = 256
[presets.dev]
processes = 1
concurrency = 16
any setting can be overridden from the CLI with -o dotted.path=value
values are parsed as JSON when possible (true, 42, ["a","b"]), otherwise kept as strings
contribution
well if you insist... (issues / PRs welcome)
#clankersgoaway
Metadata
Release files for kuu 0.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kuu-0.4.2.tar.gz | 123.1 kB | Without provenance | Details for kuu-0.4.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kuu-0.4.2-py3-none-any.whl | Python 3 | none | any | Details for kuu-0.4.2-py3-none-any.whl |
Total release size: 294.6 kB
Release files / kuu-0.4.2.tar.gz
| Download URL | kuu-0.4.2.tar.gz |
|---|---|
| Size | 123.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4c11ffcb7991496f67ff1be4c2956d247c427f9569c2f44fbf9f618200936a1
|
|
BLAKE2b-256 checksum How to use checksums |
0647c383b30b209d529bdd7cfe122037e1bc30b98f9c621d3fd49e331c97716f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / kuu-0.4.2-py3-none-any.whl
| Download URL | kuu-0.4.2-py3-none-any.whl |
|---|---|
| Size | 171.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
135dbe5e69670d658e467838f28d43fadb51fb7083b5be87523050f9e9f922d1
|
|
BLAKE2b-256 checksum How to use checksums |
0aa7bf651d1d40ba5a6b9598e2cbcea58ae4eba325fe0968289bcebb1ca6564f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for kuu 0.4.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.