Skip to main content

Lightweight Python framework for writing clean and testable event-driven services

Project description

⚡ Dispytch

Dispytch is a lightweight, async-first Python framework for event-handling. It’s designed to streamline the development of clean and testable event-driven services.

🚀 Features

  • 🧠 Async-first core – built for modern Python I/O
  • 🔌 FastAPI-style dependency injection – clean, decoupled handlers
  • 📬 Backend-flexible – with Kafka and RabbitMQ out-of-the-box
  • 🧱 Composable architecture – extend, override, or inject anything
  • 🧾 Pydantic-based validation – event schemas are validated using pydantic
  • 🔁 Built-in retry logic – configurable, resilient, no boilerplate

📦 Installation

Install using uv with extras for your preferred backend:

for Kafka support:

uv add dispytch[kafka]

For RabbitMQ support:

uv add dispytch[rabbitmq]

📚 Documentation

Full documentation is available:
👉 here


✨ Handler example

from typing import Annotated

from pydantic import BaseModel
from dispytch import Event, Dependency, HandlerGroup

from service import UserService, get_user_service


class User(BaseModel):
    id: str
    email: str
    name: str


class UserCreatedEvent(BaseModel):
    user: User
    timestamp: int


user_events = HandlerGroup()


@user_events.handler(topic='user_events', event='user_registered')
async def handle_user_registered(
        event: Event[UserCreatedEvent],
        user_service: Annotated[UserService, Dependency(get_user_service)]
):
    user = event.body.user
    timestamp = event.body.timestamp

    print(f"[User Registered] {user.id} - {user.email} at {timestamp}")

    await user_service.do_smth_with_the_user(event.body.user)

✨ Emitter example

import uuid
from datetime import datetime

from pydantic import BaseModel
from dispytch import EventBase


class User(BaseModel):
    id: str
    email: str
    name: str


class UserEvent(EventBase):
    __topic__ = "user_events"


class UserRegistered(UserEvent):
    __event_type__ = "user_registered"

    user: User
    timestamp: int


async def example_emit(emitter):
    await emitter.emit(
        UserRegistered(
            user=User(
                id=str(uuid.uuid4()),
                email="example@mail.com",
                name="John Doe",
            ),
            timestamp=int(datetime.now().timestamp()),
        )
    )

⚠️ Limitations

While dispytch is a great choice for most usecases there are some limitations to be aware of:

🧾 No schema-on-write support Dispytch uses a schema-on-read model. Formats like Avro, Protobuf, or Thrift aren’t supported yet.

🕵️ No dead-letter queue (DLQ) Failed messages are retried using built-in logic, but there’s no DLQ or fallback mechanism after final retries yet.

🧩 No topic pattern matching Wildcard or templated subscriptions (e.g. user.*, order:{id}:events) aren’t supported in handler declarations yet. Though the backend of you choice may route events to the appropriate queues/topics/channels there is no way for a dispytch handler to know it yet


💡 See something missing? Some features aren’t here yet—but with your help, they could be. Contributions welcome via PRs or discussions.

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

dispytch-0.10.0.tar.gz (754.1 kB view details)

Uploaded Source

Built Distribution

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

dispytch-0.10.0-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file dispytch-0.10.0.tar.gz.

File metadata

  • Download URL: dispytch-0.10.0.tar.gz
  • Upload date:
  • Size: 754.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for dispytch-0.10.0.tar.gz
Algorithm Hash digest
SHA256 71407b0ea00664663d7dfc826a8c9dac6e3acb3f22ada6736f3bb1b9b8158eeb
MD5 7dade04551872baf8b47687d9ade6ab8
BLAKE2b-256 174480f1e287ff8e498494dc02fbb6bcff8178881fe16edb2efe9048396fbb23

See more details on using hashes here.

File details

Details for the file dispytch-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: dispytch-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for dispytch-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 896cdd97491ef6c125fcefd52fe6797f908c79c364659d80fa6d90130e606f83
MD5 e510bd6a95d9bab643ee17e65241a0c5
BLAKE2b-256 cf37028e988592bd4228fd967b5e08e393aa511bc2b623f216092a5bfe738244

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