Mercurial > code > home > repos > homeauto
view service/reasoning/twisted_sse_demo/api_example.py @ 294:14ac4a210dbc
Copy from from https://github.com/juggernaut/twisted-sse-demo
Ignore-this: a252d3c6e023cb83fd10bfbae78e05d9
author | 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)