Skip to main content

larzbus

An in-process pub/sub event bus. Pure Python, zero dependencies.

Decouple your app: publishers announce that something happened, subscribers react, and neither knows about the other — with three things ad-hoc callback lists lack.

from larzbus import EventBus

bus = EventBus()

@bus.on("user.*")
def audit(event):
    print(event.topic, event.data)

bus.publish("user.created", {"id": 42})     # audit sees "user.created"

What makes it different

  • Wildcard topics. Subscribe to user.* (one segment) or order.** (all remaining) and get every matching event — with the concrete topic on event.topic.
  • Async delivery when you want it. bus.publish(topic, data, async_=True) runs handlers on a background thread, so one slow subscriber never blocks the publisher.
  • Dead-letter path. A handler that raises doesn't take down the publish — the other handlers still run, and the event + exception go to your on_error handlers and a dead_letters log.
  • Zero dependencies, thread-safe.

Install

pip install larzbus

Usage

from larzbus import EventBus

bus = EventBus()

# subscribe (decorator or direct); wildcards allowed
@bus.on("order.*")
def on_order(event):
    ...

sub = bus.subscribe("payment.completed", handler)
bus.once("startup", run_once)          # auto-unsubscribes after first delivery
sub.unsubscribe()

# publish
results = bus.publish("order.created", {"id": 1})   # list of handler returns
bus.publish("email.queued", payload, async_=True)    # non-blocking

# dead-letter
@bus.on_error
def failed(topic, event, exc):
    log.warning("handler failed on %s: %s", topic, exc)

bus.dead_letters      # [(topic, event, exception), ...]

Wildcards

pattern matches
user.created exactly that topic
user.* user.created, user.deleted (one more segment)
order.** order.created, order.item.added, … (any depth)

Tests

python -m unittest discover -s tests -v   # 17 tests, zero deps

The Larz stack

Pure-Python, zero-dependency building blocks: larz · larzchain · larzmoney · larzcrypt · larzdb · larzagent · larzchart · larzmark · larztask · larzvault · larzvm · larzcache · larzvalidate · larzid · larzrpc · larzstate · larzhttp · larzconf · larzcron · larzlimit · larzlog · larzcli · larzretry · larztime · larzpdf · larzpack · larztemplate · larzcolor · larztable · larzjson · larzbus

License

MIT © larz-scripter

Metadata

Release files for larzbus 0.1.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 larzbus 0.1.0
File Size Uploaded Provenance
larzbus-0.1.0.tar.gz 6.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for larzbus 0.1.0
File Interpreter ABI Platform
larzbus-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.4 kB

Release files / larzbus-0.1.0.tar.gz

Download URL larzbus-0.1.0.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b7c6931e16e08d30d586fda4f510b019785a9a18575e12d6b93c14ea964ca660
BLAKE2b-256 checksum
How to use checksums
f564171e7745a41362906fc4b194e58b8481b244a3955a7c9f104a58c7a2818c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / larzbus-0.1.0-py3-none-any.whl

Download URL larzbus-0.1.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a31bc607ab84121849812c342783b8ed5eab1fabb4745a48a3b847282ccb3dcc
BLAKE2b-256 checksum
How to use checksums
7a44726024dd847c02c1c37347e6b6e112fda5a639fd056585cd28908a26a43f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for larzbus 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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