Broadcaster provides a simple, asynchronous publish/subscribe interface for Python 3.8+, allowing for broadcast channels across various backends like Redis, PostgreSQL, and Kafka. The current version is 0.3.1. It's actively maintained by the Encode organization, known for projects like Starlette and Uvicorn, suggesting a steady, incremental release cadence.
pip install broadcasterVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates setting up an in-memory (default) or environment-variable-configured Broadcaster. It connects, publishes a message to a channel, and then subscribes and retrieves that message. Remember to set the `BROADCAST_URL` environment variable (e.g., `redis://localhost:6379`) to use a different backend, and ensure the corresponding optional dependency is installed.
Install the specific backend dependency using extras, e.g., `pip install "broadcaster[redis]"` for Redis, or `pip install "broadcaster[postgres]"` for PostgreSQL.
Add `await broadcaster.connect()` at the start of your Broadcaster operations and `await broadcaster.disconnect()` when done, or use context managers for subscriptions where applicable.
Ensure all Broadcaster operations are awaited within an `async` function and the application's event loop is properly managed (e.g., using `asyncio.run()` for top-level execution).