Consume Server-Sent Event (SSE) messages with HTTPX.
httpx-sse
Consume Server-Sent Event (SSE) messages with HTTPX.
Table of contents
Installation
Quickstart
How-To
API Reference
Installation
NOTE: This is beta software. Please be sure to pin your dependencies.
pip install httpx-sse=="0.4.*"
Quickstart
httpx-sse provides the connect_sse and aconnect_sse helpers for connecting to an SSE endpoint. The resulting EventSource object exposes the .iter_sse() and .aiter_sse() methods to iterate over the server-sent events.
Example usage:
import httpx
from httpx_sse import connect_sse
with httpx.Client() as client:
with connect_sse(client, "GET", "http:/localhost:8000/sse") as event_source:
for sse in event_source.iter_sse():
print(sse.event, sse.data, sse.id, sse.retry)
You can try this against this example Starlette server (credit):
import asyncio
import uvicorn
from starlette.applications import Starlette
from starlette.routing import Route
from sse_sta
- RPM
- python3-httpx-sse-0.4.0-1.lbn36.noarch.rpm
- Summary
- Consume Server-Sent Event (SSE) messages with HTTPX.
- URL
- https://pypi.org/project/httpx-sse
- Group
- Unspecified
- License
- ZPL
- Source
-
python-httpx-sse-0.4.0-1.lbn36.src.rpm
- Checksum
- 903e432186e6bf4a62a01f638a21b22dca3dfe02b7fd9775bf37817405aef7a3
- Build Date
- 2024/11/23 22:25:55
- Requires
- Provides
-
python-httpx-sse = 0.4.0-1.lbn36
python3-httpx-sse = 0.4.0-1.lbn36
python3.10-httpx-sse = 0.4.0-1.lbn36
python3.10dist(httpx-sse) = 0.4
python3dist(httpx-sse) = 0.4
- Obsoletes