Skip to main content

A pure Python pub/sub broker

Project description

PM-PARK

PM-PARK (Python Messaging Pub/Sub App Broker) is a pure Python pub/sub broker.

Features

  • TCP pub/sub broker
    • Exact and pattern subscriptions through fnmatch
    • str, bytes, int, and float message payloads
    • Built-in Python logging
  • CLI commands for server and client operations
  • Pure Python implementation

Requirements

  • Python >=3.12

CLI

Python API

Broker service

import time

from pm_park.server import BrokerService

try:
    with BrokerService(host="127.0.0.1", port=6379) as service:
        host, port = service.address
        print(f"Serving on {host}:{port}")
        while service.is_running:
            time.sleep(1.0)
except KeyboardInterrupt:
    pass

Client publish / subscribe

A running broker service is required to execute this example.

from pm_park.client import PMParkClient

messages: list[dict[str, object]] = []

def on_message(message: dict[str, object]) -> None:
    messages.append(message)

with PMParkClient(host="127.0.0.1", port=6379) as sub:
    sub.subscribe("news.sports", handler=on_message)
    sub.psubscribe("news.*", handler=on_message)
    sub.start()

    with PMParkClient(host="127.0.0.1", port=6379) as pub:
        pub.publish("news.sports", b"score")
        pub.publish("news.sports", 42)
        pub.publish("news.sports", 3.14)

    sub.stop()

Development Setup

This section is for developing this repository. uv is used as the primary project management tool.

Test

uv run scripts/run_tests.py --unit
uv run scripts/run_tests.py --integration

Build

uv run scripts/build_wheel.py

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 Distribution

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

pm_park-0.1.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pm_park-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pm_park-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d3f18dfca9c3a5c2dce21f407efd79ef828a7a20d959fec39304f5abf760fab0
MD5 043ec9e29853061e7b1e7030a7fa5009
BLAKE2b-256 7a59515f35a2c1ca89bb3c53ef8801dcfc7af055ff4a6e8f0a4cfbf079f7aaed

See more details on using hashes here.

Provenance

The following attestation bundles were made for pm_park-0.1.0-py3-none-any.whl:

Publisher: release.yml on a741852963a2000/pm-park

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