Skip to main content

A decentralized, brokerless pub/sub for multi-process communication on a single machine

Project description

localpub 🥃

A decentralized, brokerless pub/sub for multi-process communication on a single machine.

A local pub for your processes to hang out. 🍻

CI License: MIT Ruff

Features

  • Multiple backends: Choose the right transport for your workload:
    • Unix Domain Socket Mesh — peer-to-peer, no single point of failure
    • Unix Domain Socket Broker — competitive binding, first process becomes broker
    • mmap Ring Buffer — ultra-low-latency shared memory
  • Async-first: Modern asyncio APIs with convenient sync wrappers
  • Pluggable serialization: Pass any Python object; swap in JSON, msgpack, or your own
  • Zero external dependencies: Pure stdlib for the core package
  • Fully typed: PEP 561 compatible with strict type coverage

Quick Start

import asyncio
from localpub import UnixMeshBus

async def main():
    bus = UnixMeshBus("/tmp/mypub")
    await bus.open()

    await bus.subscribe("greetings", lambda env: print(f"Received: {env.payload}"))
    await bus.publish("greetings", {"msg": "hello from process A"})

    await asyncio.sleep(1)
    await bus.close()

asyncio.run(main())

Synchronous API

from localpub import UnixMeshBus, SyncBus

bus = SyncBus(UnixMeshBus("/tmp/mypub"))
with bus:
    bus.subscribe("greetings", lambda env: print(f"Received: {env.payload}"))
    bus.publish("greetings", "hello")

Pick a backend

Backend Latency Throughput Brokerless Use case
UnixMeshBus Low Medium Yes Resilient, no single point of failure
UnixBrokerBus Low High No (elected) General purpose, simple topology
MmapRingBus Ultra-low Very High Yes High-throughput same-machine IPC

Installation

pip install localpub

Development

# Install dependencies
make install

# Run tests
make test

# Lint & format
make lint
make format

# Type check
make typecheck

# Run all checks (lint + typecheck + test)
make check

# Build wheel and sdist
make build

License

MIT — see LICENSE.

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

localpub-0.1.1.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

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

localpub-0.1.1-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file localpub-0.1.1.tar.gz.

File metadata

  • Download URL: localpub-0.1.1.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for localpub-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bec9ffdba28f31894cd3143b29265577632dd18a9e231ed1be793dd3d51c5006
MD5 665cec2ce55491d9fc5bfd45c2fe35a5
BLAKE2b-256 e7cbf060568eec461f7cab876d69cbf4c22d2c519c9bf0832e99339a64fc66c1

See more details on using hashes here.

File details

Details for the file localpub-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: localpub-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for localpub-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7596f9b585bcfa06e7221f24cc4efc7ce80826eee49032da14e17cd7e2486c9e
MD5 78414ec202b6a5618d8c674e8591210e
BLAKE2b-256 d014a6c55f3b377ebf17b5e2b5a11fba16853a0eefc7d7fe5560b10b933d7ac9

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