Skip to main content

AsyncMQ

AsyncMQ Logo

Async task queues, workers, retries, scheduling, and operations visibility for Python.

Test Suite Package version Supported Python versions


Documentation: https://asyncmq.dymmond.com

Source Code: https://github.com/dymmond/asyncmq

Supported Version: the latest released version is the supported version.


AsyncMQ is a background job runtime for Python services built on asyncio and anyio. It gives applications a queue API, worker runtime, retry and dead-letter behavior, repeatable scheduling, flow primitives, multiple backends, a CLI, and a packaged Lilya/Jinja operations dashboard.

Why AsyncMQ

  • Task registration for Python services with @task, .enqueue(), .delay(), and .send().
  • Queue and worker APIs for retries, backoff, delayed jobs, cancellation, pause/resume, cleanup, and DLQ operations.
  • Backend options for Redis, PostgreSQL, MongoDB, RabbitMQ, and local memory-backed development.
  • A production operations console that is packaged with AsyncMQ and works without Node.js or a frontend build pipeline.
  • Clear runtime ownership: workers own execution, backends own durable queue state, and the dashboard consumes that state.

AsyncMQ is not a hosted queue service and does not promise exactly-once execution. Production task handlers should be idempotent and safe to retry.

Install

pip install asyncmq

Optional backend extras:

pip install "asyncmq[postgres]"
pip install "asyncmq[mongo]"
pip install "asyncmq[aio-pika]"
pip install "asyncmq[all]"

Quickstart

Start with the in-memory backend for local development:

# myapp/settings.py
from asyncmq.backends.memory import InMemoryBackend
from asyncmq.conf.global_settings import Settings


class AppSettings(Settings):
    backend = InMemoryBackend()
    worker_concurrency = 1
export ASYNCMQ_SETTINGS_MODULE=myapp.settings.AppSettings

Define a task:

# myapp/tasks.py
from asyncmq.tasks import task


@task(queue="emails", retries=2, ttl=300)
async def send_welcome(email: str) -> str:
    return f"sent welcome email to {email}"

Enqueue work:

# producer.py
import anyio

from asyncmq.queues import Queue
from myapp.tasks import send_welcome


async def main() -> None:
    queue = Queue("emails")
    job_id = await send_welcome.enqueue("alice@example.com", backend=queue.backend)
    print("enqueued", job_id)


anyio.run(main)

Run a worker:

asyncmq worker start emails --concurrency 1

Inspect from the CLI:

asyncmq queue list
asyncmq queue info emails
asyncmq job list --queue emails --state waiting
asyncmq job list --queue emails --state failed

Production Backend Example

Use a shared backend configuration for producers, workers, and the dashboard.

# myapp/settings.py
from asyncmq.backends.redis import RedisBackend
from asyncmq.conf.global_settings import Settings
from asyncmq.core.utils.dashboard import DashboardConfig


class AppSettings(Settings):
    secret_key = "replace-with-a-secret-from-your-secret-manager"
    backend = RedisBackend("redis://redis:6379/0")
    worker_concurrency = 8
    scan_interval = 1.0

    @property
    def dashboard_config(self) -> DashboardConfig:
        return DashboardConfig(
            secret_key=self.secret_key,
            dashboard_url_prefix="/asyncmq",
            path="/asyncmq",
            https_only=True,
        )

Workers and the dashboard can run in different services as long as they use the same ASYNCMQ_SETTINGS_MODULE and backend credentials.

Operations Dashboard

AsyncMQ includes a native dashboard built with Lilya, Jinja templates rendered by the server, and packaged static assets.

# myapp/dashboard.py
from lilya.apps import Lilya

from asyncmq.contrib.dashboard.admin import AsyncMQAdmin

app = Lilya()
admin = AsyncMQAdmin(
    enable_login=True,
    backend=auth_backend,  # Provide an AuthBackend implementation.
    url_prefix="/asyncmq",
)
admin.include_in(app)

The dashboard supports queue inspection, worker health, job lists, failed job tracebacks, DLQ actions, repeatables, metrics, runtime events, audit history, and deployments behind reverse proxies at /, /asyncmq/, and nested prefixes such as /operations/asyncmq/.

Read the Dashboard guide for authentication, separate dashboard/worker services, proxy setup, and Nginx examples.

Runtime Shape

flowchart LR
    Producer["Producer service"] --> Task["@task enqueue"]
    Task --> Queue["Queue API"]
    Queue --> Backend["Backend state"]
    Backend --> Worker["Worker runtime"]
    Worker --> Handler["Task handler"]
    Worker --> Backend
    Backend --> Dashboard["Operations dashboard"]
    Backend --> CLI["asyncmq CLI"]

Documentation Map

Download files

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

Source Distribution

asyncmq-0.9.0.tar.gz (316.8 kB view details)

Uploaded Source

Built Distribution

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

asyncmq-0.9.0-py3-none-any.whl (380.6 kB view details)

Uploaded Python 3

File details

Details for the file asyncmq-0.9.0.tar.gz.

File metadata

  • Download URL: asyncmq-0.9.0.tar.gz
  • Upload date:
  • Size: 316.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.1 {"ci":true,"cpu":"x86_64","distro":{"id":"noble","libc":{"lib":"glibc","version":"2.39"},"name":"Ubuntu","version":"24.04"},"implementation":{"name":"CPython","version":"3.10.20"},"installer":{"name":"hatch","version":"1.17.1"},"openssl_version":"OpenSSL 3.0.13 30 Jan 2024","python":"3.10.20","system":{"name":"Linux","release":"6.17.0-1018-azure"}} HTTPX2/2.6.0

File hashes

Hashes for asyncmq-0.9.0.tar.gz
Algorithm Hash digest
SHA256 3f4b002add59fe804139b1e196bbb10ae9860e92548856e3b1d2e2876f1695ad
MD5 ecf8c699a288f1996caea6b158250c13
BLAKE2b-256 415a3f01e9cd6687f055a80550c9839d28cf86f322b1e3d123dbf33885b5ca0f

See more details on using hashes here.

File details

Details for the file asyncmq-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: asyncmq-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 380.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.1 {"ci":true,"cpu":"x86_64","distro":{"id":"noble","libc":{"lib":"glibc","version":"2.39"},"name":"Ubuntu","version":"24.04"},"implementation":{"name":"CPython","version":"3.10.20"},"installer":{"name":"hatch","version":"1.17.1"},"openssl_version":"OpenSSL 3.0.13 30 Jan 2024","python":"3.10.20","system":{"name":"Linux","release":"6.17.0-1018-azure"}} HTTPX2/2.6.0

File hashes

Hashes for asyncmq-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9deea207af1764630d3506efee62221c8379ef30fcf88129ad73bed192c11ccf
MD5 b8f212aa2a4a843f6f858fce25689168
BLAKE2b-256 f62d099d6d5cdccc3b91d17912e3a10924438d410f128d6a34c06e1654fddb07

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page