Skip to content

server-sent events python client library based on requests

License

Notifications You must be signed in to change notification settings

overcat/requests-sse

Repository files navigation

requests-sse

GitHub Workflow Status PyPI Python - Version

A Server-Sent Events python client based on requests, provides a simple interface to process Server-Sent Events.

Installation

pip install requests-sse

Usage

import requests
from requests_sse import EventSource, InvalidStatusCodeError, InvalidContentTypeError

with EventSource("https://stream.wikimedia.org/v2/stream/recentchange", timeout=30) as event_source:
    try:
        for event in event_source:
            print(event)
    except InvalidStatusCodeError:
        pass
    except InvalidContentTypeError:
        pass
    except requests.RequestException:
        pass

Credits

This project was inspired by aiohttp-sse-client, aiosseclient, sseclient, and sseclient-py.

About

server-sent events python client library based on requests

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages