view lib/twisted_sse_demo/api_example.py @ 1306:2ffffcc7d0a4

some unadded files, for the record Ignore-this: d86a03897a19d3cad8ddb8a6fca13c93 darcs-hash:3ff74ca8d153c84b8f24dd6182ca15dc8a0e86fd
author drewp <drewp@bigasterisk.com>
date Sun, 21 Apr 2019 03:08:43 -0700
parents ee168d55524a
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)