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.

TLS / rediss://

For TLS-fronted Redis (ElastiCache encryption-in-transit, or any non-cluster Redis with TLS), set tls=True on Queue / Worker / QueueEvents, or pass a rediss:// URL directly:

async with Queue("emails", redis_url="redis://my-cluster.cache.amazonaws.com:6379", tls=True) as queue:
    ...
# or:
async with Queue("emails", redis_url="rediss://my-cluster.cache.amazonaws.com:6379") as queue:
    ...

Trust roots come from the platform store via rustls-native-certs: keychain on macOS, the OS CA bundle on Linux (probed by openssl-probe), system store on Windows — so AWS Trust CA-signed endpoints work out of the box. For private CAs, point SSL_CERT_FILE at a PEM bundle before launching Python; that env var takes precedence over the platform store.

Power-user surface

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

from chasquimq import Producer, Consumer, Scheduler

There is one user-facing Job — the high-level dataclass returned by Queue.add and passed to your Worker handler. The native binding's wire-format pyclass is internal-only (chasquimq._native._Job) and not re-exported (mirrors the Node shim).

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.2.0-cp39-abi3-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.9+Windows x86-64

chasquimq-1.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

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

chasquimq-1.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

chasquimq-1.2.0-cp39-abi3-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

chasquimq-1.2.0-cp39-abi3-macosx_10_12_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: chasquimq-1.2.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.2.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6737691854fe7060957fdb7bf7d5c5b3571fc2c7af49041a416d52d55ff9c8b8
MD5 f508be6a50aed6122c83c4e9cc169504
BLAKE2b-256 70cbf3d6d817066e8d25d7c76d20e4559b08218b322aab2c676ad65657985459

See more details on using hashes here.

Provenance

The following attestation bundles were made for chasquimq-1.2.0-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.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chasquimq-1.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 06a3341961026de80a365e50928d4bd078b7ac4f10503a9932d469a3156170e0
MD5 e6f90ba60675abcf7a02eb1f8643eb96
BLAKE2b-256 eba5588903a91a75c3243af2ea5ec7ba8f67d8dbdbc014c8a7dd3d28b98ab3e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for chasquimq-1.2.0-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.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for chasquimq-1.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a2f96d1e264fba81a418da8432bc975fee94933a0491be15de84507a522df0df
MD5 2efc707a0bced3b69aec83356992b9c6
BLAKE2b-256 fc2269b06e3263dc60302dd8796d013e85a1add241de0b5e21f9f7fe5d562b3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for chasquimq-1.2.0-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.2.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chasquimq-1.2.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4bc23e6f20c55358ae0bd394358d01efeb47c1d159669f6f4909efe785462073
MD5 ffbf391ed703c3f24f57613a746d7b17
BLAKE2b-256 58864451b00732af8cd4fe7772b5f9419e89cd78e7624d40dfab5f2382c7fb8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for chasquimq-1.2.0-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.2.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for chasquimq-1.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3d1afb44e0830bbb72c455b66244cef30f61093bc507bcea41e98e0217e769c9
MD5 cd5c7d3dfdcce5e3ef6ff95863b390ca
BLAKE2b-256 a8a6be09dfea1d9e696c4a4db1474272c5afa8adb55c78c34a0a3b13e35388b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for chasquimq-1.2.0-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