SSE client for Python
Project description
Server Side Events (SSE) client for Python
A Python client for SSE event sources that seamlessly integrates with urllib3 and requests.
Installation
$ pip install sseclient-py
Usage
import json
import pprint
import sseclient
def with_urllib3(url, headers):
"""Get a streaming response for the given event feed using urllib3."""
import urllib3
http = urllib3.PoolManager()
return http.request('GET', url, preload_content=False, headers=headers)
def with_requests(url, headers):
"""Get a streaming response for the given event feed using requests."""
import requests
return requests.get(url, stream=True, headers=headers)
url = 'http://domain.com/events'
headers = {'Accept': 'text/event-stream'}
response = with_urllib3(url, headers) # or with_requests(url, headers)
client = sseclient.SSEClient(response)
for event in client.events():
pprint.pprint(json.loads(event.data))
Resources
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sseclient-py-1.7.2.tar.gz
(7.7 kB
view details)
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 sseclient-py-1.7.2.tar.gz.
File metadata
- Download URL: sseclient-py-1.7.2.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba3197d314766eccb72a1dda80b5fa14a0fbba07d796a287654c07edde88fe0f
|
|
| MD5 |
90e31277d42b1b6f50fa097ed21978ca
|
|
| BLAKE2b-256 |
7d1f29688479e7e57a4cd847ded630be27b3a96f64b379e7f0136f64020f6308
|
File details
Details for the file sseclient_py-1.7.2-py2.py3-none-any.whl.
File metadata
- Download URL: sseclient_py-1.7.2-py2.py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a758653b13b78df42cdb696740635a26cb72ad433b75efb68dbbb163d099b6a9
|
|
| MD5 |
5a7bca6b660217ada919bbcd24529af6
|
|
| BLAKE2b-256 |
7467482889996a8a12767ca402e50e6abe1ecde497e7b2d3425b3ac452050a7c
|