Skip to main content

tarsk

A Python task queue whose workers hold a memory ceiling you set — without losing a task.

task with rust through the middle. The scheduler, retry state machine, lease tracking and child supervision are Rust; the only Python in the hot path is your handler.

PyPI Python License

pip install tarsk            # memory broker only
pip install tarsk-redis      # + Redis Streams
pip install tarsk-postgres   # + Postgres
pip install tarsk-amqp       # + RabbitMQ

Pick one. All four are the same tarsk with a different broker compiled in — same import, same API, same tarsk package — so installing two of them leaves you running whichever one pip unpacked last. tarsk refuses to import when it finds more than one, and a build without the backend your URL asks for names the package you want.

Upgrading from 0.1.x: this is a breaking change. pip install tarsk has shipped Redis, Postgres and AMQP since 0.1. From 0.2.0 it ships none of them — it is the memory-broker build. If your broker URL is anything but memory://, pip uninstall tarsk and install the package for your broker. Nothing in your code changes. See CHANGELOG.md.

Status: early. The version badge above reads live from PyPI — a number written here went stale twice before this sentence replaced it. Wheels for Linux (glibc and musl, x86_64 and aarch64), macOS universal2 and Windows x64, on Python 3.11 through 3.14 including the free-threaded build. See What is missing.

📖 Documentation — everything below the fold lives there: how it works, writing tasks, routing and scheduling, operating, benchmarks.

# pip install tarsk-redis
from tarsk import App

app = App(broker="redis://localhost:6379/0")

@app.task(retries=3, timeout=30, queue="heavy")
def embed_document(doc_id: str) -> dict:
    ...

task_id = embed_document.send("abc")
tarsk worker --app myapp:app --broker redis://localhost:6379/0 \
             --queues heavy --children 4 --max-rss 400MB --metrics 0.0.0.0:9090

Handlers must be idempotent. Delivery is at-least-once. This is a contract, not a footnote: a worker killed mid-task will run that task again.

What it does that others do not

child RSS over one hour under a leaky handler, and the supervisor holding it

One hour, 72,001 tasks, a handler that never frees anything. 66 recycles, peak 400 MB against a 400 MB ceiling, no sample over it, nothing killed, nothing lost. The flat line beneath the sawtooth, on the same axis, is the supervisor doing the holding: 28.32 to 28.40 MB across the hour, a drift of 82 KB. A ceiling enforced from inside a process with the same problem would only defer it.

Every Python task queue leaks, because leaks come from the code they run rather than from the queue. The difference is what the runtime does about it.

--max-rss is a byte budget. Celery's --max-tasks-per-child is a task count, which only bounds bytes if you already know how many bytes a task costs — and stays wrong once that changes. Same configuration, different workloads:

leak 20MB/task leak 40MB/task payload-dependent 2–80MB
celery --max-tasks-per-child=6 162 MB 282 MB 327 MB
tarsk --max-rss=200MB 183 MB 183 MB 187 MB

Celery wins the first column, and that is the honest result: when the leak per task is known and constant, dividing the budget by it works — someone divided 200 by 20 and typed 6. It is the other two columns tarsk was built for: nothing was reconfigured between them, the workload moved, and the guess encoded in that 6 went with it.

The worker that runs your code is 27 MB against Celery's 41 MB and taskiq's 44 MB, because it imports your tasks and nothing else — no broker driver, no scheduler. Recycling costs 7 ms at the 99th percentile against Celery's 139 ms, because the replacement child starts before the trigger fires and the slot never goes empty.

What it does not claim

Not faster. With a 50 ms handler tarsk, Celery and taskiq all reach 19–20 tasks/s. Draining 10,000 no-op tasks across four processes: Celery 10.0s, taskiq 2.3s, tarsk 2.2s — ahead in every run and by 4%, which this project's own benchmark rules call a tie. It starts in half the time and runs in half the memory; that is the claim, and speed is not.

This file claimed a 1.45× lead until the numbers were checked on more than one machine. The full retraction, and every column where tarsk loses, is in the benchmarks.

Not a hard ceiling regardless of task size. The ceiling is read at the dispatch decision, and a handler that allocates 300 MB will allocate it. Overshoot is bounded by the peak of whatever is in flight when the limit is crossed — with --slots 1 that is one task, because the child is idle at the moment it is read; at the default of 100 slots it is up to 100. The budget divides the remaining headroom by the measured per-task cost, so that number is usually far below the slot count, but the only way to bound it at one task is --slots 1.

Not durable execution. That is Temporal's category, and it is much heavier.

What is missing

  • No chord. chain and group are here; fanning back in to a callback is not
  • Windows runs the suites that need no broker, since neither Redis nor Postgres ships for it. Everything else — the channel, recycling, the memory ceiling — is tested there

Running the tests

The toolchain is pinned in mise.toml — Rust 1.94.0 and Python 3.14.3, the versions the published numbers were produced with. With mise installed, mise install fetches both and entering the directory creates .venv from the pinned Python. Without it, any Python 3.11+ and a recent stable Rust will build: the wheel is abi3-py311.

python -m venv .venv && .venv/bin/pip install maturin msgpack
# Every backend in one build: the published wheels take one each, the source
# tree is where all four are tested.
.venv/bin/maturin develop --release -F redis,postgres,amqp

.venv/bin/python tests/test_ipc.py       # protocol, timeouts, retries
.venv/bin/python tests/test_recycle.py   # the ceiling, soft timeouts, middleware
.venv/bin/python tests/test_brokers.py   # all four brokers end to end
cargo test --lib                         # cron, console, socket permissions

The broker tests start their own redis-server and Postgres cluster, use any RabbitMQ answering on the conventional ports, and skip whichever is missing — loudly, so a skip cannot pass for a pass. TARSK_REDIS_URL, TARSK_PG_URL and TARSK_AMQP_URL point them at servers you already have instead, which is how a machine without the server binaries still tests those backends. Give each one a database of its own. python demo/run.py --minutes 1 --ceiling 150MB --rate 30 is the definition of done in miniature: it exits non-zero if a task goes missing or the supervisor drifts.

License

MIT — see LICENSE.

Download files

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

Source Distribution

tarsk_amqp-0.2.1.tar.gz (132.6 kB view details)

Uploaded Source

Built Distributions

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

tarsk_amqp-0.2.1-cp314-cp314t-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.14tWindows x86-64

tarsk_amqp-0.2.1-cp314-cp314t-musllinux_1_2_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

tarsk_amqp-0.2.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64

tarsk_amqp-0.2.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.7 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

tarsk_amqp-0.2.1-cp314-cp314t-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (5.8 MB view details)

Uploaded CPython 3.14tmacOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

tarsk_amqp-0.2.1-cp311-abi3-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.11+Windows x86-64

tarsk_amqp-0.2.1-cp311-abi3-musllinux_1_2_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ x86-64

tarsk_amqp-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

tarsk_amqp-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

tarsk_amqp-0.2.1-cp311-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (5.8 MB view details)

Uploaded CPython 3.11+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file tarsk_amqp-0.2.1.tar.gz.

File metadata

  • Download URL: tarsk_amqp-0.2.1.tar.gz
  • Upload date:
  • Size: 132.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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 tarsk_amqp-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2e5d284c06d31814b3adb9b71001daf0ff3fa983de4927e7e4b069d17781d2f1
MD5 72c69f1e81fdd65d910f7828593ba5e2
BLAKE2b-256 2e9ab6801ed25e9d67f237d32429e46769c5d2e90a2f477b1deac40445c703ee

See more details on using hashes here.

File details

Details for the file tarsk_amqp-0.2.1-cp314-cp314t-win_amd64.whl.

File metadata

  • Download URL: tarsk_amqp-0.2.1-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.14t, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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 tarsk_amqp-0.2.1-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 89dd7672ebb526fed05f917c51af39f1b5f44cd216fd01cc7c666eec620ac1d4
MD5 3d632a48805bd2f8dc98d0465b608dd4
BLAKE2b-256 2aeb5dad14afa23ead3bb5710e38872894e65801cc86a23810266af462443193

See more details on using hashes here.

File details

Details for the file tarsk_amqp-0.2.1-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: tarsk_amqp-0.2.1-cp314-cp314t-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.14t, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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 tarsk_amqp-0.2.1-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 68555bd29e470fe15f1558451110eee009a5d202b87e03437b7628c0eb1b2286
MD5 bf72a1a6a7421138026a9a7cc57dd6fd
BLAKE2b-256 fa139d7834cddc535bb6742b5e99326ee31a0d5745828a9343a399f194250e03

See more details on using hashes here.

File details

Details for the file tarsk_amqp-0.2.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: tarsk_amqp-0.2.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.14t, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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 tarsk_amqp-0.2.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4161f7a221e3979c30be3846e5d5f546a8615443e6c20fc0336106b0985b68b2
MD5 6243f2166f7a52871b90d1e9d17d9b7d
BLAKE2b-256 43ca0976e0869e7007c8b71da37eb997dfd9d7f59ead6ff4afe89cc14640a9f0

See more details on using hashes here.

File details

Details for the file tarsk_amqp-0.2.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: tarsk_amqp-0.2.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.14t, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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 tarsk_amqp-0.2.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 baa1177adf5cd15eb736b070bff005834616447aa243ef655016e2f163eaec92
MD5 3d51f383844d6d6ff4be461607b669bb
BLAKE2b-256 9d45eb2d1a8c88d37b247cc60f6d3496fcd312d2f2831f5d0f405570e6a72ee9

See more details on using hashes here.

File details

Details for the file tarsk_amqp-0.2.1-cp314-cp314t-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

  • Download URL: tarsk_amqp-0.2.1-cp314-cp314t-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
  • Upload date:
  • Size: 5.8 MB
  • Tags: CPython 3.14t, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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 tarsk_amqp-0.2.1-cp314-cp314t-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 c65a812be4812eae224c634c753c114b6a2fea8e30192e4db6983e680098bd20
MD5 d50bfb96c13fa61eee76e7baec5edd8a
BLAKE2b-256 ca390925bf5b9857db025ac1f3baabafc582535b25abc99e9dd096d01babdf99

See more details on using hashes here.

File details

Details for the file tarsk_amqp-0.2.1-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: tarsk_amqp-0.2.1-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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 tarsk_amqp-0.2.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1154d4ce515fae456797d21e45eadf3b306c608563ae6405e2ae12426628ca40
MD5 05479cc31a7ed1a1dcbf9748f5395460
BLAKE2b-256 cd861d1253a2b200a785cbbb4f29b30d5f0be8d586f7d7f4e0d6a1aa27d503b9

See more details on using hashes here.

File details

Details for the file tarsk_amqp-0.2.1-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: tarsk_amqp-0.2.1-cp311-abi3-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.11+, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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 tarsk_amqp-0.2.1-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8c43e75635b3e8a21c12a2d959ecc97759c3c3a221a6664cf0980fedec5310cd
MD5 35352942f1bf06ba22b6d6dd2bd723a7
BLAKE2b-256 82c13acf3e6b9475ca3ff0b577b02884df0f037a08e1e28435c91ddacaf602c3

See more details on using hashes here.

File details

Details for the file tarsk_amqp-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: tarsk_amqp-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 3.3 MB
  • Tags: CPython 3.11+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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 tarsk_amqp-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab7e52a624b29740f56994ad61c6440f6ca2459c3b2e8a2dbbd0458e7c688edc
MD5 1814162e803fc166807caed0a3858e4a
BLAKE2b-256 b644cf5657474484050e766b0801e4b9591929d7e30911ab51f9d47e2b1c7614

See more details on using hashes here.

File details

Details for the file tarsk_amqp-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: tarsk_amqp-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.11+, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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 tarsk_amqp-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f2c35d3b9ff55f6343b1838e4af384f18decaeda9275ef51971bbb842499802b
MD5 911f9ff5273bc8161c504281fe46a8e5
BLAKE2b-256 67aab436ad6481f4fbd81dc17b6cd917c72a6ed0a854cefb166a6dc0e1430fca

See more details on using hashes here.

File details

Details for the file tarsk_amqp-0.2.1-cp311-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

  • Download URL: tarsk_amqp-0.2.1-cp311-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
  • Upload date:
  • Size: 5.8 MB
  • Tags: CPython 3.11+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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 tarsk_amqp-0.2.1-cp311-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 b6b13f4132429d8acaaff7561e5b4b1d4cea8b2cd61494a82c4b7947847238a7
MD5 7a51243adb3369667ef5052edc62f5ad
BLAKE2b-256 63a61522c487a4dacb0af9e50f6bafaa1adc4b439eec4a0a2bc14f929950d415

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.1 This release

11 files

0.2.0

11 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page