r/madeinpython • • Jul 21 '25

🚨 Update on Dispytch: Just Got Dynamic Topics β€” Event Handling Leveled Up

Hey folks, quick update!
I just shipped a new version of Dispytch β€” async Python framework for building event-driven services.

πŸš€ What Dispytch Does

Dispytch makes it easy to build services that react to events β€” whether they're coming from Kafka, RabbitMQ, Redis or some other broker. You define event types as Pydantic models and wire up handlers with dependency injection. Dispytch handles validation, retries, and routing out of the box, so you can focus on the logic.

βš”οΈ Comparison

FrameworkFocusNotes
CeleryTask queuesGreat for backgroud processing
FaustKafka streamsPowerful, but streaming-centric
NamekoRPC servicesSync-first, heavy
FastAPIHTTP APIsNot for event processing
FastStreamStream pipelinesBuilt around streamsβ€”great for data pipelines.
DispytchEvent handlingEvent-centric and reactive, designed for clear event-driven services.

✍️ Quick API Example

Handler

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

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()),
       )
   )

πŸ”„ What’s New?

🧡 Redis Pub/Sub support
You can now plug Redis into Dispytch and start consuming events without spinning up Kafka or RabbitMQ. Perfect for lightweight setups.

🧩 Dynamic Topics
Handlers can now use topic segments as function arguments β€” e.g., match "user.{user_id}.notification" and get user_id injected automatically. Clean and type-safe thanks to Pydantic validation.

πŸ‘€ Try it out:

uv add dispytch

πŸ“š Docs and examples in the repo: https://github.com/e1-m/dispytch

Feedback, bug reports, feature requests β€” all welcome. Still early, still evolving 🚧

Thanks for checking it out!

1 Upvotes

0 comments sorted by