Skip to main content

lightweight async distributed task queue

Project description

kuu

PyPI Python License Downloads

kuu


a native distributed task queue for python

uv add kuu
# extras: msgspec, nats, prometheus, redis, dashboard

nothing serious in this project, just got tired of taskiq's undefined behaviour and logging.getLogger("root")

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 .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.schedule.cron(expr="* * */4 * * *")
async def refresh_balance() -> None: ...


# myapp/main.py
from .tasks import charge


async def run() -> None:
    # type checker will automatically infer here
    # that handle is type of TaskHandle[ChargeResult]
    # args/kwargs of the task also remain typed
    handle = await charge.q(user_id=1, amount_cents=500)

    # type checker will infer ChargeResult
    result = await handle.result(timeout=30)
# reads ./kuunfig.toml or [tool.kuu] in ./pyproject.toml
uv run kuu start

# pick a preset and override specific settings
uv run kuu start -p prod -o concurrency=128 -o dashboard.enable=true

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]
app = "myapp.module:instance"            # dotted path to the Kuu instance
task_modules = ["myapp.tasks"]           # modules that register tasks

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

[metrics]
enable = false
host = "0.0.0.0"
port = 9191

[dashboard]
enable = false
host = "0.0.0.0"
port = 8181
path = "/dashboard"

[scheduler]
enable = false                           # run scheduler loop in-process; jobs declared via app.schedule

[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

[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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kuu-0.1.5.post2.tar.gz (51.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kuu-0.1.5.post2-py3-none-any.whl (76.5 kB view details)

Uploaded Python 3

File details

Details for the file kuu-0.1.5.post2.tar.gz.

File metadata

  • Download URL: kuu-0.1.5.post2.tar.gz
  • Upload date:
  • Size: 51.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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}

File hashes

Hashes for kuu-0.1.5.post2.tar.gz
Algorithm Hash digest
SHA256 eb7dc84901dd195b2d8edc6d9ba845eb50733694fc09cc1590c56e9be32db4ae
MD5 84e415eba7c1194fbfc91087cba844e1
BLAKE2b-256 f4b733c5cd8d9e2cad685782fb7cb4e41a154ddaab265683d0d10fd68c2e03e5

See more details on using hashes here.

File details

Details for the file kuu-0.1.5.post2-py3-none-any.whl.

File metadata

  • Download URL: kuu-0.1.5.post2-py3-none-any.whl
  • Upload date:
  • Size: 76.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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}

File hashes

Hashes for kuu-0.1.5.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 b5b235a65d611bc53a559101913b6e500b3fd3a9e7766cf4c3118520ab55c00f
MD5 3362fe47d27f9a3fbf509b40784fd472
BLAKE2b-256 d0067330fc2e5b3560fe27ae6c560d8ca37761869d0642bd30d78a70107a9e6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page