Server Sent Events protocol implemetation on python2/3
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.



Server Sent Events protocol implemetation on python2 and python3 in the same codebase.

Python tested versions:

  • Python 2.7.x
  • Python 3.2.x
  • PyPy 1.9.0r

Api documentation:


Constructor. On this method is called, automaticali initialize the internal buffer with retry statement with 2000ms as default value.


Method for set a custom retry value on initialized Sse intance.


The specification of sse indicates that you can put ids to events. For more info, see:

With this method, can set or reset the id value.


Helper method for reseting event id.

Sse.add_message(event, text, encoding='utf-8')

Method for add messages to the buffer and associate this messages to events. The event parameter can be a unicode string and text can be string, list, tuple or set.


Clears the internal buffer.


Returns a raw output of buffer, ready for set to client. NOTE: this method will be used only on python3.


Returns a raw output of buffer. Same as __str__ but returns unicode value on python2. Is not used on python3.

Aditional info:

  • Sse instance object can be used as iterator. On finish the iteration the internal buffer is automaticaly cleared.
  • Can use dynamic methods Sse.add_event_eventname(text='foo') as alias of Sse.add_message('eventname', 'foo')


BSD License