view lib/twisted_sse_demo/api_example.py @ 447:3d51d4b63497

patchsource py3 support. might break py2 Ignore-this: e7559afeb74ffa53bf2085f78455014
author drewp@bigasterisk.com
date Thu, 18 Apr 2019 21:58:19 -0700
parents 7716b1810d6c
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)