Skip to main content

Python asynchronous client for interacting with LowMQ

Project description

LowMQ Python Client

PyPI version Python versions License: MIT

An ergonomic, type-annotated, asyncio-based client for LowMQ — a lightweight message queue.

Highlights

  • Async-first API built on top of aiohttp
  • Fully type-annotated, ships py.typed for type checkers
  • Safe JSON handling and helpful exceptions
  • Pluggable aiohttp session and configurable timeouts
  • Tiny footprint, minimal required deps

Install

Using pip:

pip install lowmq-client

For development (linters, tests, etc.):

pip install -e .[dev]
pre-commit install

Using uv (fast Python package manager):

# Install uv with pipx (recommended)
pipx install uv

# Sync the project (installs core + dev, as configured)
uv sync

# Activate the virtual environment that uv manages
# Windows PowerShell:
. .venv\Scripts\activate
# Linux/macOS:
# source .venv/bin/activate

pre-commit install

Quickstart

import asyncio
from lowmq_client import LowMqClient

async def main() -> None:
    base_url = "https://your-lowmq-server.com"
    auth_key = "your-auth-key"

    async with LowMqClient(auth_key, base_url) as client:
        # Add a message to a queue
        add_res = await client.add_packet("payments", {"amount": 100}, freeze_time_min=5)
        print("added:", add_res)

        # Get a message from a queue (and keep it in the queue)
        msg = await client.get_packet("payments", delete=False)
        print("fetched:", msg)

        # Delete a message by id
        if msg and "_id" in msg:
            ok = await client.delete_packet("payments", msg["_id"])
            print("deleted:", ok)

asyncio.run(main())

API

  • LowMqClient(auth_key: str, lowmq_url: str | pydantic.AnyUrl, session: Optional[aiohttp.ClientSession] = None, timeout: Optional[aiohttp.ClientTimeout] = None)
    • Asynchronous client. Can re-use an external aiohttp session.
  • await set_auth_key(auth_key: str) -> None
  • await set_lowmq_url(lowmq_url: str | pydantic.AnyUrl) -> None
  • await add_packet(queue_name: str, payload: Any, freeze_time_min: int = 5) -> dict
    • POST /msg?freezeTimeMin=...
  • await get_packet(queue_name: str, delete: bool = False) -> dict
    • GET /msg?key=...&delete=true|false
  • await delete_packet(queue_name: str, packet_id: str) -> bool
    • DELETE /msg?key=...&_id=...

Exceptions

  • LowMqError — base class for client exceptions
  • InvalidUrlError — invalid LowMQ base URL
  • ClientClosedError — client used without an active session
  • ApiError — server returned non-2xx, includes status, reason, and parsed body when possible

Typing

This package is fully typed and includes a py.typed marker. You can rely on type checkers (mypy/pyright) to validate your usage. The public API returns standard Python types (dict) for server responses; you can define your own Pydantic models if you prefer stronger typing for message payloads.

Recipes

  • Reusing your aiohttp session:
import aiohttp
from lowmq_client import LowMqClient

session = aiohttp.ClientSession()
client = LowMqClient("key", "https://lowmq.example", session=session)
# ... use client inside an async context as usual ...
  • Custom timeout:
import aiohttp
from lowmq_client import LowMqClient

client = LowMqClient(
    "key",
    "https://lowmq.example",
    timeout=aiohttp.ClientTimeout(total=10),
)

Development

  • Lint and format (Ruff):
ruff check .
ruff format .
  • Tests:
python -m unittest -v
  • Pre-commit hooks:
pre-commit install
pre-commit run --all-files

Links

License

MIT

Project details


Download files

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

Source Distribution

lowmq_client-1.0.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

lowmq_client-1.0.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file lowmq_client-1.0.0.tar.gz.

File metadata

  • Download URL: lowmq_client-1.0.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lowmq_client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 384d9384f7188b518aac6c6c72dda8bbbdd26a7c0ab8c286c845036b785bd245
MD5 7cdcaa0f5873b2b6762bcf7ba56d48f7
BLAKE2b-256 d684063b2c324f5ffb17464b135d44a2bab2c9b4213e7dc6c82ff50a52d0cc55

See more details on using hashes here.

File details

Details for the file lowmq_client-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: lowmq_client-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lowmq_client-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0e764ef69813d3eda166bfe38871da245cabf718691aa77a10db4a9e8cbe28c
MD5 93d14b672ca6aa344772c70643e16973
BLAKE2b-256 7ffe6a5ff0c9f5cf6edbf4b65ed0e1c13f5272ce2682430c324f7fd838e45d8e

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 Pingdom Monitoring Sentry Error logging StatusPage Status page