resumable-sse
Asynchronous recoverable SSE (Server-Sent Events) push toolkit, supporting Redis and in-memory backend.
✨ Features
- ✅ Seamless integration with async generators (
async for) - 🔁 Resumable message stream support with
Last-Event-ID - 💾 Backend-agnostic: in-memory or Redis support
- ⚙️ Clean abstraction, minimal API surface
- 🧪 Easy to test, extendable for custom storage backends
📦 Installation
pip install resumable-sse
Or from source:
git clone https://github.com/vvanglro/resumable-sse.git
cd resumable-sse
pip install -e .
🚀 Quick Start
Using with FastAPI:
import asyncio
from fastapi import FastAPI, Request
from sse_starlette.sse import EventSourceResponse
from resumable_sse.factory import get_streamer
app = FastAPI()
streamer = get_streamer(backend="memory")
async def fake_generator():
for word in ["Hello,", "I'm an AI.", "Nice to meet you."]:
yield word
await asyncio.sleep(1)
@app.get("/stream")
async def stream(request: Request, session_id: str):
return EventSourceResponse(
streamer.stream(session_id=session_id, generator=fake_generator())
)
Supports resume with:
GET /stream?session_id=abc
🔌 Redis Backend Example
import redis.asyncio as redis
from resumable_sse.factory import get_streamer
redis_client = redis.Redis()
streamer = get_streamer(backend="redis", redis_client=redis_client)
📘 API Reference
async def stream(
self,
session_id: str,
generator: ContentStream,
last_id: str = "0",
) -> AsyncGenerator[dict, None]:
session_id: Unique ID per conversation or stream sessionlast_id: Resume position (used withLast-Event-ID)generator: Async generator function that yields message chunks
🧪 Run Tests
pytest tests/
📁 Project Structure
resumable_sse/
├── base.py # Abstract base class
├── memory.py # In-memory implementation
├── redis.py # Redis implementation
├── factory.py # Factory for backend selection
├── __init__.py
README.md
pyproject.toml
📄 License
MIT License
Metadata
Release files for resumable-sse 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| resumable_sse-0.1.0.tar.gz | 20.7 kB | Without provenance | Details for resumable_sse-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| resumable_sse-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for resumable_sse-0.1.0-py3-none-any.whl |
Total release size: 26.8 kB
Release files / resumable_sse-0.1.0.tar.gz
| Download URL | resumable_sse-0.1.0.tar.gz |
|---|---|
| Size | 20.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95f089d6df06309d97a5da36bba10ccf2520699e1848bdca1d599d87f6557c16
|
|
BLAKE2b-256 checksum How to use checksums |
7adc66330266bd98ebb91a095dec8a9024fe0cff26b3ebfebd5abfae2a72ca7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.20
|
Release files / resumable_sse-0.1.0-py3-none-any.whl
| Download URL | resumable_sse-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a46ad3b981ffb8006b729fc0fcf605de20143ffeff140cbd48ec1794b69c4f07
|
|
BLAKE2b-256 checksum How to use checksums |
2739c8d3eae6836a0e9586741fc3e243e0f69d7d6b6134dbc8b880a9cd0dbfeb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.20
|
Security for resumable-sse 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.