Skip to main content

A tiny, pythonic SDK for the ZigMQ text protocol.

Project description

zigMQ Python SDK

zigmq is a tiny, pythonic SDK for the ZigMQ text protocol.

By default, the SDK connects to 127.0.0.1:8388.

The goal of this SDK is deliberately narrow:

  • one small sync client for queue/admin commands
  • one dedicated subscriber client for pub/sub delivery
  • no dependency, no ORM-style abstraction, no magic reconnect layer
  • protocol-compatible with the current ZigMQ server behavior

Install

pip install zigmq

Local development:

cd zigMQ-python-SDK
pip install -e .
python -m unittest -v

Quick Start

from zigmq import Client

with Client() as mq:
    mq.send("jobs", "hello world")
    print(mq.recv("jobs"))

Pub/Sub:

from zigmq import Client, Subscriber

with Subscriber() as sub:
    sub.subscribe("news")

    with Client() as mq:
        delivered = mq.publish("news", "shipped")
        print(delivered)

    event = sub.get()
    print(event.topic, event.message)

API

Client

  • ping() -> str
  • info() -> Info
  • send(queue, message) -> None
  • recv(queue) -> str
  • recv_bytes(queue) -> bytes
  • peek(queue) -> str
  • peek_bytes(queue) -> bytes
  • queue_length(queue) -> int
  • create_queue(queue) -> None
  • list_queues() -> list[str]
  • publish(topic, message) -> int
  • list_topics() -> dict[str, int]
  • subscriber(*topics) -> Subscriber

Short protocol-style aliases are also available: mq, len, queues, pub, topics.

Subscriber

  • subscribe(*topics) -> None
  • unsubscribe(*topics) -> None
  • get(timeout=None) -> Event
  • iteration support: for event in sub: ...

Design Notes

  • This SDK is text-first, because ZigMQ itself is a line-based text protocol.
  • The default connection target is 127.0.0.1:8388.
  • Queue/topic names cannot contain whitespace or line breaks.
  • Message bodies can contain spaces, but cannot contain \\r or \\n.
  • queues, topics, and info follow the current ZigMQ server behavior and are parsed from multi-line responses.

Publish To PyPI

Update version in pyproject.toml, then:

cd zigMQ-python-SDK
python -m build
twine upload dist/*

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

zigmq-0.1.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

zigmq-0.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zigmq-0.1.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for zigmq-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bffa45c118e7209e57127067e18ce2444136b4c6fe8641e7045deea5652df9b8
MD5 93bffab1d2ecebf374f86b19be2e7491
BLAKE2b-256 028720000f763012d9507fdd2975dbe54ab7511beec8a6a29fe92c98f91b6340

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zigmq-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for zigmq-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc72be30af4df3d2b531e12a39e004dcf48910cc002c47d36592f9a572118ba0
MD5 c315b819fe7224fdc8e159956def2096
BLAKE2b-256 1fd89a1c7f2589827c13bf7963319f24c0dddd75394fd32dcb9921fb24ebc181

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