Skip to content

Commit

Permalink
Use aclosing() around ws async gen
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed Jul 8, 2022
1 parent 2e3cac1 commit 8984c1b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions piker/brokers/kraken/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
Union,
)

from async_generator import aclosing
from bidict import bidict
import pendulum
import trio
Expand Down Expand Up @@ -316,6 +317,7 @@ async def trades_dialogue(
),
) as ws,
trio.open_nursery() as n,
aclosing(stream_messages(ws)) as stream,
):
# task local msg dialog tracking
emsflow: dict[
Expand All @@ -339,7 +341,7 @@ async def trades_dialogue(

# enter relay loop
await handle_order_updates(
ws,
stream,
ems_stream,
emsflow,
ids,
Expand All @@ -351,7 +353,7 @@ async def trades_dialogue(


async def handle_order_updates(
ws: NoBsWs,
ws_stream: NoBsWs,
ems_stream: tractor.MsgStream,
emsflow: dict[str, list[MsgUnion]],
ids: bidict[str, int],
Expand All @@ -372,7 +374,7 @@ async def handle_order_updates(
# on new trade clearing events (aka order "fills")
trans: list[pp.Transaction]

async for msg in stream_messages(ws):
async for msg in ws_stream:
match msg:
# process and relay clearing trade events to ems
# https://docs.kraken.com/websockets/#message-ownTrades
Expand Down

0 comments on commit 8984c1b

Please sign in to comment.