More cleanup, add comments re sub func

small_kucoin_fixes
jaredgoldman 2023-03-19 13:27:31 -04:00
parent 1c4c19b351
commit 50e1070004
1 changed files with 11 additions and 1 deletions

View File

@ -441,8 +441,14 @@ async def stream_quotes(
@acm @acm
async def subscribe(ws: wsproto.WSConnection): async def subscribe(ws: wsproto.WSConnection):
@acm @acm
async def open_ping_task(ws: wsproto.WSConnection): async def open_ping_task(ws: wsproto.WSConnection):
'''
Ping ws server every ping_interval
so Kucoin doesn't drop our connection
'''
async with trio.open_nursery() as n: async with trio.open_nursery() as n:
async def ping_server(): async def ping_server():
@ -504,7 +510,11 @@ def make_sub(sym, connect_id) -> dict[str, str | bool]:
} }
async def stream_messages(ws: NoBsWs, sym: str) -> AsyncGenerator[NoBsWs, dict]: async def stream_messages(
ws: NoBsWs,
sym: str
) -> AsyncGenerator[NoBsWs, dict]:
timeouts = 0 timeouts = 0
while True: while True: