A decentralized, brokerless pub/sub for multi-process communication on a single machine.
A local pub for your processes to hang out. 🍻
- 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
asyncioAPIs 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
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())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")| 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 |
pip install localpub# 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 buildMIT — see LICENSE.