Trace log the heartbeat

its_happening
Tyler Goodlet 2020-08-02 01:35:29 -04:00
parent 9e4ee4d382
commit 72d6b5b06f
1 changed files with 9 additions and 0 deletions

View File

@ -181,11 +181,20 @@ async def stream_quotes(
async def recv():
return json.loads(await ws.get_message())
import time
async def recv_ohlc():
last_hb = 0
while True:
msg = await recv()
if isinstance(msg, dict):
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
err = msg.get('errorMessage')
if err: