A lightweight, pure-Python event dispatcher for building decoupled applications.
PyPI CI Status LicenseKey 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
pip install whistle
Requires Python 3.10 or later. No dependencies.
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')
For complete documentation, visit https://python-whistle.readthedocs.io/
- Homepage: https://python-whistle.github.io/
- Documentation: https://python-whistle.readthedocs.io/
- PyPI: https://pypi.org/project/whistle/
- Source Code: https://github.com/python-whistle/whistle
- Issue Tracker: https://github.com/python-whistle/whistle/issues
Made with β₯ by Romain Dorgueil and contributors.