view service/reasoning/twisted_sse_demo/api_example.py @ 1099:cb94ea3495b2

Copy from from https://github.com/juggernaut/twisted-sse-demo Ignore-this: a252d3c6e023cb83fd10bfbae78e05d9 darcs-hash:bd76fd3b996c7225f03930b3796dc4ddc7783d9a
author drewp <drewp@bigasterisk.com>
date Fri, 19 Aug 2016 10:53:03 -0700
parents
children
line wrap: on
line source

import time

from eventsource import EventSource

EVENTSOURCE_URL = 'http://localhost:12000/subscribe'

def onmessage(data):
    print 'Got payload with data %s' % data

if __name__ == '__main__':
    eventSource = EventSource(EVENTSOURCE_URL)
    eventSource.onmessage(onmessage, callInThread=True)
    time.sleep(20)