LaunchDarkly SSE Client
Actively maintained. Last release 6 weeks ago, commits in 9 of the last 26 weeks. A safe choice.
pip install launchdarkly-eventsourceLaunchDarkly SSE Client for Python
Overview
The launchdarkly/python-eventsource package allows Python developers to consume Server-Sent-Events (SSE) from a remote API. The SSE specification is defined here: https://html.spec.whatwg.org/multipage/server-sent-events.html
This package's primary purpose is to support the LaunchDarkly SDK for Python, but it can be used independently. In its simplest configuration, it emulates the behavior of the EventSource API as defined in the SSE specification, with the addition of exponential backoff behavior for retries. However, it also includes optional features used by LaunchDarkly SDKs that are not part of the core specification, such as:
- Customizing the backoff/jitter behavior.
- Setting read timeouts, custom headers, and other HTTP request properties.
- Specifying that connections should be retried under circumstances where the standard EventSource behavior would not retry them, such as if the server returns an HTTP error status.
The default SSEClient is a synchronous implementation which blocks the caller's thread when reading events or reconnecting. By default, it uses urllib3 to make HTTP requests, but it can be configured to read any input stream.
An async implementation, AsyncSSEClient, is also available for use with asyncio-based applications. It uses aiohttp for HTTP and requires installing the optional async extra:
pip install launchdarkly-eventsource[async]
[!CAUTION] The async implementation (
AsyncSSEClientand its associatedAsyncConnectStrategyAPI) is experimental and should NOT be considered ready for production use. It may change or be removed without notice and is not subject to backwards compatibility guarantees.