kopia lustrzana https://github.com/projecthorus/pysondehub
example subscriber to live updates
play with blocking/unblocking connections to us-east-1.amazonaws.com and see msg count drop to zero/picking up again after unblockingpull/2/head
rodzic
ff447ac37a
commit
4a2f60d2da
|
@ -0,0 +1,32 @@
|
|||
import json
|
||||
import time
|
||||
import sondehub
|
||||
|
||||
interval = 5
|
||||
msgs = 0
|
||||
elapsed = 0
|
||||
starttime = 0
|
||||
log = True
|
||||
|
||||
def on_msg(*args):
|
||||
global msgs
|
||||
msgs +=1
|
||||
|
||||
def on_connect(*args):
|
||||
print("on_connect:", *args)
|
||||
|
||||
def on_disconnect(*args):
|
||||
print("on_disconnect:", *args)
|
||||
|
||||
def on_log(*args):
|
||||
if log:
|
||||
print(f"on_log:", *args)
|
||||
|
||||
sh = sondehub.Stream(on_message=on_msg,
|
||||
on_disconnect=on_disconnect,
|
||||
on_log=on_log,
|
||||
on_connect=on_connect);
|
||||
while True:
|
||||
time.sleep(interval)
|
||||
print(f"tick {msgs=}")
|
||||
msgs = 0
|
Ładowanie…
Reference in New Issue