Trace log the heartbeat

unleash_the_kraken
Tyler Goodlet 2020-08-02 01:35:29 -04:00
parent bf9a0136df
commit e92abd376a
1 changed files with 9 additions and 0 deletions

View File

@ -181,11 +181,20 @@ async def stream_quotes(
async def recv(): async def recv():
return json.loads(await ws.get_message()) return json.loads(await ws.get_message())
import time
async def recv_ohlc(): async def recv_ohlc():
last_hb = 0
while True: while True:
msg = await recv() msg = await recv()
if isinstance(msg, dict): if isinstance(msg, dict):
if msg.get('event') == 'heartbeat': if msg.get('event') == 'heartbeat':
log.trace(
f"Heartbeat after {time.time() - last_hb}")
last_hb = time.time()
# TODO: hmm i guess we should use this
# for determining when to do connection
# resets eh?
continue continue
err = msg.get('errorMessage') err = msg.get('errorMessage')
if err: if err: