Skip to main content

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):
    """Get a streaming response for the given event feed using urllib3."""
    import urllib3
    http = urllib3.PoolManager()
    return http.request('GET', url, preload_content=False)

def with_requests(url):
    """Get a streaming response for the given event feed using requests."""
    import requests
    return requests.get(url, stream=True)

url = 'http://domain.com/events'
response = with_urllib3(url)  # or with_requests(url)
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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sseclient_py-1.5-py2.py3-none-any.whl (5.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file sseclient_py-1.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for sseclient_py-1.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 108b44ba48a76d23c4e40c854b6f8c1eed8922def1d6a2c64e0ec59dc3b2a204
MD5 88f476559a5a9aaea6ffda76d3ada432
BLAKE2b-256 7917b5c5dbe60f755542fb23cb0ca10f67e70e00913d44bc03cf1f8d934a91ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page