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

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

Uploaded CPython 3.9+Windows x86-64

chasquimq-1.1.0-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.1.0-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.1.0-cp39-abi3-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

chasquimq-1.1.0-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.1.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: chasquimq-1.1.0-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.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 80deaec3b6f93091f9585a162c477f51adf850baf500c4b11ef51f7790a0c9e0
MD5 fd8ee704b9780ca925b6fd3d1f36c209
BLAKE2b-256 77abf71b11ec5c7fe0a20c70b84e4675c9300ca1ec632f7fbbd3a29fb6c911f8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for chasquimq-1.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 38694b978da6c3b1400352ae2d88b7b179c5d7145653a6d34870bbade5a0e15a
MD5 d6bc4aed97f46992ff222adc255a347f
BLAKE2b-256 3069dbef4a9d4566855c2d4f3a10e48eacf6020facb126657d1c1e153c637033

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for chasquimq-1.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a92164d71612ed283eaa35f1ec609cee273548e9f3e0f8a16db94aa78fa340d5
MD5 f231e54571f750bbc27a19584ddd9237
BLAKE2b-256 d1acc256e7832a05b088f5739a5600ada80cc26ed735fea62c63885f3a7e0858

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for chasquimq-1.1.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1d71199f451efa3f340d7486a8317e70e3c321e460226d8c94de83d9e4324a92
MD5 dcc2dcdc2cf5ac62406897c63b31d1f4
BLAKE2b-256 812c437db371143a40fb2928ca31884628ed9d5739592ad5c252890b3542aa9e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for chasquimq-1.1.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c94d2428b59b63583b59b1e2c4ee09d7b99b70bb5279f690006bc52afba25d3e
MD5 a119a0022818b2e39342580c23a6c2b5
BLAKE2b-256 2a77469d5e3fcf2579ecc1ab73d9278960856d72df3c73ef27754e555258b36c

See more details on using hashes here.

Provenance

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