larzsse
Server-Sent Events — server and client. Pure Python, no async, zero deps.
SSE is the simplest way to push a live stream of events from server to browser
(or any client) over plain HTTP — one long-lived text/event-stream response.
larzsse gives you both ends: a thread-safe Broadcaster that fans events out to
every connected client, and a client that connects and iterates parsed events.
from larzsse import Broadcaster, connect
bus = Broadcaster()
server = bus.serve("127.0.0.1", 8080) # streams at /events
bus.publish("hello", event="greeting") # every client receives it
for ev in connect("http://127.0.0.1:8080/events"):
print(ev.event, ev.data)
Why
- Both ends included. A
Broadcaster(subscribe/publish/unsubscribe, with keepalives and a built-in threaded server) and aconnect()client that parses the stream intoEvent(event, data, id)objects. - No async, no dependency. Plain sockets and threads — a lightweight complement to WebSockets (larzws) when you only need server → client push (live dashboards, progress, notifications, log tailing).
- Correct wire format.
format_event/parse_eventshandledata:/event:/id:/retry:, multiline data, and comment keepalives — round-trip clean.
Install
pip install larzsse
Usage
from larzsse import Broadcaster, connect, format_event
bus = Broadcaster()
bus.serve("0.0.0.0", 8080, path="/events")
bus.publish("payload", event="update", id="42")
bus.client_count
# embed in your own server: stream a subscribed client's events()
client = bus.subscribe()
for chunk in client.events(): # SSE strings; write to the response
...
# client
for ev in connect("http://host/events"):
ev.event, ev.data, ev.id
Tests
python -m unittest discover -s tests -v # 13 tests incl. live SSE over HTTP
The Larz stack
One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter.
License
MIT © larz-scripter
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file larzsse-0.1.0.tar.gz.
File metadata
- Download URL: larzsse-0.1.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fde2fbaf8cd40c793a7f2059188cfc28bdcf6f045683233a5df6ef984a19ffe7
|
|
| MD5 |
0972b1e0a9875bf61f2071d9c8c35ada
|
|
| BLAKE2b-256 |
bd37f68328faeb9f802a593d3d6ff2a34228cc970ec860066047cb05f7ea55c0
|
File details
Details for the file larzsse-0.1.0-py3-none-any.whl.
File metadata
- Download URL: larzsse-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
722e414db45113692e56f43e46b25e4428fad8550ab060dac57011fdb5e82806
|
|
| MD5 |
02dbab8a373ce525474297803127b81a
|
|
| BLAKE2b-256 |
45da32951dbae1a8ba00a23ca5d365166b99074f19316662b9ba1c26b5fe06e7
|