From 50e1070004472443f6986c653b7f50a14d40b9c4 Mon Sep 17 00:00:00 2001 From: jaredgoldman Date: Sun, 19 Mar 2023 13:27:31 -0400 Subject: [PATCH] More cleanup, add comments re sub func --- piker/brokers/kucoin.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/piker/brokers/kucoin.py b/piker/brokers/kucoin.py index 35d8f690..1f87e701 100644 --- a/piker/brokers/kucoin.py +++ b/piker/brokers/kucoin.py @@ -441,8 +441,14 @@ async def stream_quotes( @acm async def subscribe(ws: wsproto.WSConnection): + @acm 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 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 while True: