Skip to main content

Server Sent Events protocol implemetation.

Project description

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:

Sse.__init__(default_retry=2000)

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

Sse.set_retry(num)

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

Sse.set_event_id(event_id)

The specification of sse indicates that you can put ids to events. For more info, see: http://www.w3.org/TR/eventsource/#concept-event-stream-last-event-id

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

Sse.reset_event_id()

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.

Sse.flush()

Clears the internal buffer.

Sse.__str__()

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

Sse.__unicode__()

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')

License:

BSD License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sse-1.0.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file sse-1.0.tar.gz.

File metadata

  • Download URL: sse-1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sse-1.0.tar.gz
Algorithm Hash digest
SHA256 c7a927a78e7117d6eb1674eb3e2f2d1d813215911d12158568a00f5566f05d40
MD5 decd7815f67e57a7a8f468eb7e6b75d3
BLAKE2b-256 f8de5f9f00839c4300764a00b301e415b2d5041423eff26ea844be069146bfe9

See more details on using hashes here.

Supported by

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