Skip to content

python-whistle/whistle

Repository files navigation

Whistle

A lightweight, pure-Python event dispatcher for building decoupled applications.

PyPI CI Status License

Key Features:

  • 🚀 Pure Python - No external dependencies
  • 🔄 Sync & Async - Full support for both synchronous and asynchronous workflows
  • 🎯 Type Safe - Prevents mixing sync and async listeners
  • 📦 Lightweight - Minimal footprint, maximum flexibility
  • 🎛️ Priority Control - Order listener execution
  • Event Propagation - Stop event flow when needed

Installation

pip install whistle

Requires Python 3.10 or later. No dependencies.

Quick Start

Create an event dispatcher:

from whistle import EventDispatcher

dispatcher = EventDispatcher()

Add a listener to react to events

def on_spectacle_starts(event):
    print('Please turn down your phones!')

dispatcher.add_listener('spectacle.starts', on_spectacle_starts)</code></pre>

Dispatch!

dispatcher.dispatch('spectacle.starts')

Documentation

For complete documentation, visit https://python-whistle.readthedocs.io/

Links


Made with ♥ by Romain Dorgueil and contributors.