Skip to main content

⚡ EventWire

Zero-dependency async & sync in-process event bus and decoupled messaging engine for Python.

PyPI version Python versions License: MIT Tests Typing


💡 Why EventWire?

In modern Python backends (FastAPI, Django, asynchronous microservices, workflow agents), modules frequently need to communicate without tightly coupling themselves to one another.

Instead of calling 5 different services directly inside an HTTP route or having to spin up heavyweight distributed brokers (Celery, Kafka, RabbitMQ) just for in-process communication, EventWire provides a high-performance, strictly typed in-memory event bus.


✨ Features

  • ⚡ Sync & Async Support: Emit synchronously (bus.emit) or asynchronously (await bus.emit_async) with concurrent or sequential execution.
  • 🏷️ First-Class Type Safety: Use dataclasses or class hierarchies as events with full IDE autocompletion (py.typed).
  • 🎯 Wildcard Subscriptions: Subscribe to topics with glob patterns (e.g. order.*, user.*, *).
  • 🔢 Priority Ordering: Control execution order with prioritized listeners (e.g. priority=100 before priority=0).
  • 🛡️ Dead-Letter Queue (DLQ): Fault-tolerant error recording with full stack traces, inspection, and recovery.
  • 🔌 Middleware Pipeline: Intercept events globally for logging, metrics, tracing, or validation.
  • 🛑 Propagation Control: Stop event propagation anytime (event.stop_propagation()).
  • 📦 Zero Dependencies: Built purely with Python standard library (asyncio, dataclasses, inspect).

🚀 Quickstart

1. Installation

pip install eventwire

2. Basic Synchronous Pub/Sub

from eventwire import EventBus, Event

bus = EventBus()

class UserRegistered(Event):
    def __init__(self, username: str, email: str):
        super().__init__()
        self.username = username
        self.email = email

@bus.on(UserRegistered, priority=10)
def send_welcome_email(event: UserRegistered):
    print(f"📧 Sending welcome email to {event.email}")

@bus.on(UserRegistered, priority=5)
def provision_account(event: UserRegistered):
    print(f"👤 Provisioning workspace for {event.username}")

# Emit event
bus.emit(UserRegistered("alice", "alice@example.com"))

3. Asynchronous Concurrent Dispatch

import asyncio
from eventwire import EventBus, Event

bus = EventBus()

class ImageUploaded(Event):
    def __init__(self, image_id: str):
        super().__init__()
        self.image_id = image_id

@bus.on(ImageUploaded)
async def generate_thumbnail(event: ImageUploaded):
    await asyncio.sleep(0.1)
    print(f"🖼️ Thumbnail created for {event.image_id}")

@bus.on(ImageUploaded)
async def index_metadata(event: ImageUploaded):
    await asyncio.sleep(0.05)
    print(f"🔍 Metadata indexed for {event.image_id}")

# Run both handlers concurrently via asyncio.gather
asyncio.run(bus.emit_async(ImageUploaded("img_123"), concurrent=True))

4. Wildcards and Priority Ordering

bus = EventBus()

@bus.on("auth.*")
def audit_auth_events(event_name):
    print(f"Audit log: {event_name}")

@bus.on("*", priority=-100)
def global_telemetry(event_name):
    print(f"Telemetry record: {event_name}")

bus.emit("auth.login")
bus.emit("auth.password_reset")

5. Dead-Letter Queue (DLQ) & Resilience

bus = EventBus()

@bus.on("payment.charge")
def process_payment(event):
    raise TimeoutError("Stripe gateway unreachable")

# Suppress errors so critical flows aren't interrupted
bus.emit("payment.charge", suppress_errors=True)

# Inspect failed events in DLQ
print(f"Failed events: {bus.dlq.count()}")
for letter in bus.dlq.get_all():
    print(f"Failed handler: {letter.handler_name}")
    print(f"Exception: {letter.error}")

🧪 Testing

python -m pytest

📄 License

MIT License. Copyright (c) 2026 Hamidreza.

Metadata

Release files for eventwire 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 eventwire 0.1.0
File Size Uploaded Provenance Actions
eventwire-0.1.0.tar.gz 13.3 kB With provenance Details for eventwire-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 25.1 kB

Release files / eventwire-0.1.0.tar.gz

Download URL eventwire-0.1.0.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
34ac85b53aebdb01ae6c30067b0f0dfd7c2cd06e84123a4edb7203efa482da53
BLAKE2b-256 checksum
How to use checksums
57b27815bc0c63e5d24d9074f7ad2bd94553c00ffe40a1570b3f196d00e5810d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

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

Download URL eventwire-0.1.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa4b6b1ffcc50c0009c5a1487e4f9884326104e4be60c331378c5ed9aea0bb07
BLAKE2b-256 checksum
How to use checksums
859d610166a311ed7f81be1eb973cd95ea129d172959a4aa2299771d00747ce3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for eventwire 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for eventwire-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

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 Full 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