Skip to main content

The fastest open-source message broker for Redis.

Project description

chasquimq (Python)

Python bindings for ChasquiMQ — the fastest open-source message broker for Redis. The Rust engine pulls jobs; Python asyncio handlers process them.

Status: 1.0. abi3 wheels for Python 3.9+ on Linux (x86_64 + aarch64), macOS (x86_64 + aarch64), Windows (x86_64).

Install

pip install chasquimq

Quickstart

import asyncio
from chasquimq import Queue, Worker, Job, BackoffSpec, UnrecoverableError


async def send_email(job: Job) -> dict:
    to = job.data["to"]
    print(f"sending to {to} (attempt {job.attempts_made + 1})")
    if "@unrecoverable" in to:
        raise UnrecoverableError(f"hard bounce: {to}")
    return {"sent_at": time.time(), "to": to}


async def main() -> None:
    async with Queue("emails") as queue, \
               Worker("emails", send_email, store_results=True) as worker:

        # Plain enqueue.
        await queue.add("welcome", {"to": "ada@example.com"})

        # Stable jobId — second call with the same id is a no-op (idempotent).
        await queue.add_unique(
            "welcome", {"to": "alice@example.com"},
            job_id="welcome:alice",
        )

        # Per-job retry with exponential backoff.
        await queue.add(
            "welcome", {"to": "grace@flaky.example"},
            attempts=3,
            backoff=BackoffSpec.exponential(100, multiplier=2.0, max_ms=10_000),
        )

        # Delayed enqueue (in milliseconds; for `timedelta` use delay= instead).
        await queue.add("welcome", {"to": "ka@later.example"}, delay_ms=2_000)

        # Block on a single job's result, with timeout.
        job = await queue.add("welcome", {"to": "ada@example.com"})
        result = await job.wait_for_result(timeout=30.0)
        print(result)

        # Drain the worker.
        await worker.run()


asyncio.run(main())

What's in the box

Surface What it does
Queue Producer + queue inspection. add / add_bulk / add_unique / get_job_result / peek_dlq / replay_dlq / cancel_delayed / get_repeatable_jobs / remove_repeatable_by_key. Async context manager.
Worker Consumer pool. asyncio-first dispatch, opt-in result storage (store_results=True), graceful shutdown. Async context manager.
Job Frozen dataclass returned by Queue.add. Has id, name, data, attempts_made, wait_for_result(timeout=).
QueueEvents Asyncio iterator over the engine events stream. Cross-process pub/sub for completed / failed / dlq / retry-scheduled / delayed.
BackoffSpec Builders: .fixed(delay_ms) / .exponential(initial_ms, multiplier, max_ms, jitter_ms).
RepeatPattern Builders: .cron(expr, tz=) / .every(interval_ms). DST-aware via IANA tz names.
MissedFiresPolicy .skip() / .fire_once() / .fire_all(max_catchup) for cron catch-up after scheduler downtime.
UnrecoverableError Raise from your handler to bypass retries and route the job directly to DLQ.

Power-user surface

The native engine handles ship from the same top-level package:

from chasquimq import Producer, Consumer, Scheduler

The high-level Job dataclass owns the unqualified Job name; if you need the native value-type, import it explicitly:

from chasquimq._native import Job as NativeJob

Build from source

cd chasquimq-py
python -m venv .venv && source .venv/bin/activate
pip install maturin
maturin develop          # editable install
pytest tests/            # smoke + integration tests (requires Redis 8.6+)
maturin build --release  # wheels under target/wheels/

See also

License

MIT — see LICENSE at the workspace root.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

chasquimq-1.0.3-cp39-abi3-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.9+Windows x86-64

chasquimq-1.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

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

chasquimq-1.0.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

chasquimq-1.0.3-cp39-abi3-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

chasquimq-1.0.3-cp39-abi3-macosx_10_12_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file chasquimq-1.0.3-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: chasquimq-1.0.3-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for chasquimq-1.0.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ae70e094e10caa0c90f1850c8ca619beb2dba940cf1fbb8ec6de9d7efb35d34a
MD5 acaaf0eeea8c03fb867a1d99cab03653
BLAKE2b-256 ed31b6f18ed48a40741778575496538ac3746d57c79ba4a3b0304c41d1d9632d

See more details on using hashes here.

Provenance

The following attestation bundles were made for chasquimq-1.0.3-cp39-abi3-win_amd64.whl:

Publisher: py-ci.yml on jotarios/chasquimq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chasquimq-1.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chasquimq-1.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e7fd867f249298f626056e23ab2aad39a4dba18634fdbf6fbd076323e25367c1
MD5 042ee3eb219da79f029f50ddecc818be
BLAKE2b-256 23a183425b541afc7414a7df88f4ed6707ef83ad87d23b2e24a33d0208929778

See more details on using hashes here.

Provenance

The following attestation bundles were made for chasquimq-1.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: py-ci.yml on jotarios/chasquimq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chasquimq-1.0.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for chasquimq-1.0.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9ec281a9de76b342b0db09e648577f602f8ec7ecfb46bdaaf4639384810f3cbf
MD5 bc265951f4f3bd944ffabb37e011238c
BLAKE2b-256 a4d035641cc487bf93147b72ce0f5ef53a3aba44de8fd43780eff5f4ed8bd3e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for chasquimq-1.0.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: py-ci.yml on jotarios/chasquimq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chasquimq-1.0.3-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chasquimq-1.0.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5ff4269266b39bcd4d1b5fe9f2474e2fea677912fcc2c7de1969673c40b0a0bb
MD5 85799cbdf3c35f2930a0aaf3790ef22f
BLAKE2b-256 d90277ad1343c665ee060b9824f1a21330bf3702239268e4bb9fcd8eaf589a63

See more details on using hashes here.

Provenance

The following attestation bundles were made for chasquimq-1.0.3-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: py-ci.yml on jotarios/chasquimq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chasquimq-1.0.3-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for chasquimq-1.0.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3dcb77ecb1f8aeb58fd783c9f115aa92db10aa2909d7f4c1b21e7dc2036346fa
MD5 58a93b3274e1a54f8e2364868d2ccdd6
BLAKE2b-256 8432fc20453767eaac5efcdd98ddeca7adfe18fbefe9d8aefea5b6ff98ec6df5

See more details on using hashes here.

Provenance

The following attestation bundles were made for chasquimq-1.0.3-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: py-ci.yml on jotarios/chasquimq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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