Skip to main content
SSE
===

Simple asyncio/aiohttp wrapper for Server-Sent Events.

Usage
-----

Sending events:

```python
import asyncio
import sse


class Handler(sse.Handler):
@asyncio.coroutine
def handle_request(self):
yield from asyncio.sleep(2)
self.send('foo')
yield from asyncio.sleep(2)
self.send('bar', event='wakeup')

start_server = sse.serve(Handler, 'localhost', 8888)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
```

Validating incoming requests:

```python
class Handler(sse.Handler):
def validate_sse(self):
super().validate_sse()
# use self.request / self.payload
if not self.request.path.startswith('/live'):
raise sse.SseException()
```

Sending JSON data:

```python
class Handler(sse.Handler):
@asyncio.coroutine
def handle_request(self):
self.send({'foo': 'bar'})
```

Sending IDs / event names / retry information:

```python
class Handler(sse.Handler):
@asyncio.coroutine
def handle_request(self):
self.send('some data', id=12345, event='something', retry=10000)
```

Download files

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

Source Distribution

asyncio-sse-0.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asyncio_sse-0.1-py33-none-any.whl (5.2 kB view details)

Uploaded Python 3.3

File details

Details for the file asyncio-sse-0.1.tar.gz.

File metadata

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

File hashes

Hashes for asyncio-sse-0.1.tar.gz
Algorithm Hash digest
SHA256 abba9240f92fbf69617e4865cd7dafda9bd38265d2f9447970a34f6945076acf
MD5 009303177d457ce017aed73fc4a01b33
BLAKE2b-256 74a7af14384cd397dab9619441cbaf974c19838b1df88f278f531d6979d5e749

See more details on using hashes here.

File details

Details for the file asyncio_sse-0.1-py33-none-any.whl.

File metadata

File hashes

Hashes for asyncio_sse-0.1-py33-none-any.whl
Algorithm Hash digest
SHA256 81cf9757e023c91998f8243fa5db1632eb8d0174a6c9da466c085345a603e1c8
MD5 cf013e44169fbfd4e02cc9e9ffc31567
BLAKE2b-256 3b314a319452374caa3d16c44ee16ae33df0cf1a8de4683a8d73e135d7317f9c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page