Skip to main content

py-stinger-nng

Stinger-style IPC (signals, properties, methods) over NNG — a Python pub/sub broker implementing the IBrokerConnection interface with topic filtering, retained state, and cross-platform networking.

Features

  • Topic-filtered subscriptions: Subscribe to specific topics or topic prefixes
  • Retained state: Messages marked with retain=True are stored by the server and delivered to clients that join later
  • Client-to-client relaying: The server can relay messages between clients
  • Background connection management: Both client sockets dial in the background; reconnection is automatic after server restarts
  • Thread-safe: Safe to call from multiple threads and from within message callbacks

Installation

pip install py-stinger-nng

Quick Start

from py_stinger_nng import StingerNngServer, StingerNngClient
from pystingerconniface import Message

# Start a server on ports 15555 (publish) and 15556 (receive)
with StingerNngServer(15555, 15556) as server:
    # Create a client
    with StingerNngClient(15555, 15556) as client:
        # Subscribe to a topic
        def on_message(msg: Message) -> None:
            print(f"Received: {msg.topic} = {msg.payload}")
        
        client.subscribe("sensor/", on_message)
        
        # Publish a message
        msg = Message(topic="sensor/temperature", payload=b"21.5")
        client.publish(msg).result()

Architecture

  • StingerNngServer: Runs on two ports — PUB socket for publishing, PULL socket for receiving. Dispatches messages to all matching subscriptions, manages retained state, and relays client messages.
  • StingerNngClient: Connects to the server with SUB and PUSH sockets. Handles topic filtering at the socket level and syncs retained state on connect.

Key Methods

Both StingerNngServer and StingerNngClient implement IBrokerConnection:

  • publish(message) → Future[None]: Send a message
  • subscribe(topic, callback=None, qos=1) → int: Subscribe to a topic, returns a subscription ID
  • unsubscribe(sub_id_or_topic) → bool: Cancel a subscription by ID, or every subscription to a topic
  • add_message_callback(callback): Register a callback for all unsubscribed messages
  • close(): Shut down the connection
  • is_connected() → bool: Check connection status
  • client_id → str: The unique identifier for this connection
  • online_topic → str | None: The topic for liveness announcements (if configured)

See examples/pubsub.py for a complete working example.

Metadata

Release files for py-stinger-nng 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-stinger-nng 0.2.0
File Size Uploaded Provenance Actions
py_stinger_nng-0.2.0.tar.gz 60.5 kB Without provenance Details for py_stinger_nng-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-stinger-nng 0.2.0
File Interpreter ABI Platform Actions
py_stinger_nng-0.2.0-py3-none-any.whl Python 3 none any Details for py_stinger_nng-0.2.0-py3-none-any.whl

Total release size: 73.1 kB

Release files / py_stinger_nng-0.2.0.tar.gz

Download URL py_stinger_nng-0.2.0.tar.gz
Size 60.5 kB
Tags Source
SHA-256 checksum
How to use checksums
eea84341352b57a8b8408ebf87d82c230b42e02c07d2e2e545e057d6e85b319a
BLAKE2b-256 checksum
How to use checksums
7a23bd2a870bd807c7df95beab13e2fd10117bda48d6adb1981dd536fd20f650
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / py_stinger_nng-0.2.0-py3-none-any.whl

Download URL py_stinger_nng-0.2.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec1f0dc93fe158f2e09d0aa19cc2f8aad40ad8a65ba0df4f22dda32b05f5d8dd
BLAKE2b-256 checksum
How to use checksums
aa07fac4a6e845008e2ce02007a3fd4fd4a5e0847fbd3a3af315eca168d1f702
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for py-stinger-nng 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page