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-0.1.0.tar.gz (7.7 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-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for lowmq_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 579a6dcb75962534942f704041a9715f44cc2e89d6e5c715a10a2cdac97cbc8e
MD5 ed262041acac591eb7c9da3dc80c3de4
BLAKE2b-256 4dd1f4751adc9c2e54fe536e6f3be989a7cd0b3d98ae5d228f39d03652139bf3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lowmq_client-0.1.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-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a15e8232783bc5d2ca0495fa58d43329d2301c69f44e3aec0c83bc391896682e
MD5 065f7c4ef21f2ad97db4fde572220814
BLAKE2b-256 8737a6809cf17135f039223eefb5287de60b51d54e48913f2a58e80fcd407d51

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