Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install sseclient

How to install sseclient

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install sseclient
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
0.0.4
0.0.5Never BuiltWhy not?
0.0.4 Available View build log
Linux (64-bit)
0.0.5 Available View build log
0.0.4 Available View build log
 
Author
Dependencies
Depended by
Imports
Lastest release
version 0.0.5 on May 14th, 2013

This is a Python client library for iterating over http Server Sent Event (SSE) streams. The SSEClient class accepts a url on init, and is then an iterator over messages coming from the server.

Installation

Use pip:

pip install sseclient

Usage

from sseclient import SSEClient

messages = SSEClient('http://mysite.com/sse_stream/')
for msg in messages:
    do_something_useful(msg)

Each message object will have a 'data' attribute, as well as optional 'event', 'id', and 'retry' attributes.

Optional init parameters:

  • last_id: If provided, this parameter will be sent to the server to tell it to return only messages more recent than this ID.
  • retry: Number of milliseconds to wait after disconnects before attempting to reconnect. The server may change this by including a 'retry' line in a message. Retries are handled automatically by the SSEClient object.

You may also provide any additional keyword arguments supported by the Requests library, such as a 'headers' dict and a (username, password) tuple for 'auth'.

Development

Install the test dependencies:

pip install pytest mock

And run the tests:

$ py.test
================== test session starts ===================
platform linux2 -- Python 2.7.3 -- pytest-2.3.4
collected 9 items

test_sseclient.py .........

================ 9 passed in 0.31 seconds ================

There are a couple TODO items in the code for getting the implementation completely in line with the finer points of the SSE spec.

Additional Resources

Subscribe to package updates

Last updated May 14th, 2013

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.