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]

✨ 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.9.1.tar.gz (769.7 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.9.1-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dispytch-0.9.1.tar.gz
  • Upload date:
  • Size: 769.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for dispytch-0.9.1.tar.gz
Algorithm Hash digest
SHA256 3e7cf5dec6c480a6d0a1f474cb073a09274b228cb1d1c235f553c9ab3580c1d5
MD5 d0106946afe858a7aec895265d44dd58
BLAKE2b-256 5e15f70be16d9fea8bf96d83b04a94c289daf933b46e3bf3f9c44d825b819d0d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dispytch-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for dispytch-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d50eb412b92ea2b6eb60f5514892151896006163978c1c64a831dc7512d81d39
MD5 3a0aae392933b5afca79e44c8a00cdb1
BLAKE2b-256 cc0cfd56e670a390405ca15003dde5dfc4ad5cc53b77d524c286f76d77f79534

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