Mercurial > code > home > repos > homeauto
comparison lib/twisted_sse/api_example.py @ 1313:630e0d1846b8
mv twisted_sse
Ignore-this: a59fadbe80bc4a393b1dab8228e022c1
darcs-hash:dc218d166be8566000cc59eabaa71b2f9667fe9b
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Mon, 22 Apr 2019 21:58:09 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1312:3c732f3f9f65 | 1313:630e0d1846b8 |
---|---|
1 import time | |
2 | |
3 from eventsource import EventSource | |
4 | |
5 EVENTSOURCE_URL = 'http://localhost:12000/subscribe' | |
6 | |
7 def onmessage(data): | |
8 print('Got payload with data %s' % data) | |
9 | |
10 if __name__ == '__main__': | |
11 eventSource = EventSource(EVENTSOURCE_URL) | |
12 eventSource.onmessage(onmessage, callInThread=True) | |
13 time.sleep(20) |