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.

Upgrading from 0.2: broker failures now raise tarsk.BrokerError instead of ValueError, and the workers of a fleet are best upgraded together. The four things worth knowing are at the top of 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.

Metadata

Release files for tarsk-postgres 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tarsk-postgres 0.3.0
File Size Uploaded Provenance Actions
tarsk_postgres-0.3.0.tar.gz 154.2 kB Without provenance Details for tarsk_postgres-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tarsk-postgres 0.3.0
File Actions
tarsk_postgres-0.3.0-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details for tarsk_postgres-0.3.0-cp314-cp314t-win_amd64.whl
tarsk_postgres-0.3.0-cp314-cp314t-musllinux_1_2_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64 Details for tarsk_postgres-0.3.0-cp314-cp314t-musllinux_1_2_x86_64.whl
tarsk_postgres-0.3.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 Details for tarsk_postgres-0.3.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
tarsk_postgres-0.3.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64 Details for tarsk_postgres-0.3.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
tarsk_postgres-0.3.0-cp314-cp314t-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64 Details for tarsk_postgres-0.3.0-cp314-cp314t-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
tarsk_postgres-0.3.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for tarsk_postgres-0.3.0-cp311-abi3-win_amd64.whl
tarsk_postgres-0.3.0-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details for tarsk_postgres-0.3.0-cp311-abi3-musllinux_1_2_x86_64.whl
tarsk_postgres-0.3.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for tarsk_postgres-0.3.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
tarsk_postgres-0.3.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for tarsk_postgres-0.3.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
tarsk_postgres-0.3.0-cp311-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64 Details for tarsk_postgres-0.3.0-cp311-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Total release size: 31.2 MB

Release files / tarsk_postgres-0.3.0.tar.gz

Download URL tarsk_postgres-0.3.0.tar.gz
Size 154.2 kB
Tags Source
SHA-256 checksum
How to use checksums
422d36fd59c60a34fef228fa02eb840bd3b314886b89133b500f215bac1cb422
BLAKE2b-256 checksum
How to use checksums
1ee84c3a1c8db8322b21a106746ebab639033d892481287c60665e21cc081982
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.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}

Release files / tarsk_postgres-0.3.0-cp314-cp314t-win_amd64.whl

Download URL tarsk_postgres-0.3.0-cp314-cp314t-win_amd64.whl
Size 2.4 MB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
88c88dc5bb6c7956a7e43ff7c6070711659655750923eec2259ba9fea4430455
BLAKE2b-256 checksum
How to use checksums
9fc5181098287430f498a97f50c55d85a34c7d1031e9085ab45edac17a7d9717
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.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}

Release files / tarsk_postgres-0.3.0-cp314-cp314t-musllinux_1_2_x86_64.whl

Download URL tarsk_postgres-0.3.0-cp314-cp314t-musllinux_1_2_x86_64.whl
Size 3.0 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
74b500660922043f7450fb51e9b1d5cbc36c24eec53cfd9524cf007fd56a7791
BLAKE2b-256 checksum
How to use checksums
757f60922c1f56c19e0aa5d5b8d8d4dce73088c43d4bccc8f33a7314a632bf53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.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}

Release files / tarsk_postgres-0.3.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL tarsk_postgres-0.3.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 2.8 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
85cf5bac95490f7773c45d89a3f3e7042189bf5c243c1ac38efa3d831852e336
BLAKE2b-256 checksum
How to use checksums
03511be34d6b258fb6910f77c06f2b9adc0b99672f6574d645f3d451dd668cbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.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}

Release files / tarsk_postgres-0.3.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL tarsk_postgres-0.3.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 2.4 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
f91c7d28ad5c67b2183b32a4239f7bebc7c92a2d83b88c872566254cbcc776fa
BLAKE2b-256 checksum
How to use checksums
cbb3a6722212eb1003ba85a232968dca79b4988a9f75deaaf5df9b2c0fca7cdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.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}

Release files / tarsk_postgres-0.3.0-cp314-cp314t-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL tarsk_postgres-0.3.0-cp314-cp314t-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 4.9 MB
Tags CPython 3.14 CPython 3.14 free-threading macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
09717e5a053c6f2b2fa59d03341083126a6218af94180e13757720c2d981504b
BLAKE2b-256 checksum
How to use checksums
7cfa7066ad8b78cc2de8fc0bb18643316915d302b7268c68dd32c993f371cbc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.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}

Release files / tarsk_postgres-0.3.0-cp311-abi3-win_amd64.whl

Download URL tarsk_postgres-0.3.0-cp311-abi3-win_amd64.whl
Size 2.4 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c7bf606b5dd966d3ca13a14e28b656256845203fc38226e9aeab9844564343b9
BLAKE2b-256 checksum
How to use checksums
b92667431d0066f2a5cc40e114858831d470cce12d2a11c14f5efdbef7803465
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.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}

Release files / tarsk_postgres-0.3.0-cp311-abi3-musllinux_1_2_x86_64.whl

Download URL tarsk_postgres-0.3.0-cp311-abi3-musllinux_1_2_x86_64.whl
Size 3.0 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
03170c76f96f20bd55a961be52cbd6a05c3e1407d0414f30bb540c5ef9bf37b1
BLAKE2b-256 checksum
How to use checksums
d5fc02f31ab80e62ac0ead98c6796c13ab9c6d4646740ccb3fcc36397f2fa346
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.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}

Release files / tarsk_postgres-0.3.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL tarsk_postgres-0.3.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 2.8 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
72b7ba73242fb32d0822f70a2c4290b1f109a5b8f34cc6e40ef3192f8701965a
BLAKE2b-256 checksum
How to use checksums
9cef3e6a137e24011c7dec35e74faff2dc8da24b7edaed5e9dddad04e503326d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.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}

Release files / tarsk_postgres-0.3.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL tarsk_postgres-0.3.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 2.4 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
102653d4c69b8056847127677e47bc3d6c1c03f17aedbf1210387b676b3aeab2
BLAKE2b-256 checksum
How to use checksums
bc5586b2fc754a2344b8a6ee5707665cdc2aeaf04db52a7cbaa63fae2f5ff742
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.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}

Release files / tarsk_postgres-0.3.0-cp311-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL tarsk_postgres-0.3.0-cp311-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 4.9 MB
Tags CPython 3.11 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d82fda7da235f5b50be31e5551be976951aada4ccbfca961055e191e8cad2529
BLAKE2b-256 checksum
How to use checksums
349acd0cac76df0f5079c6577917805ccc0cb73ca2c0b148b3a5be104e1df7de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.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}

Security for tarsk-postgres 0.3.0

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.

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