Always close emsd data connection on close

cached_feeds
Tyler Goodlet 2021-04-05 08:06:28 -04:00
parent 1281755d65
commit 47f823ab22
1 changed files with 10 additions and 2 deletions

View File

@ -191,7 +191,6 @@ async def maybe_open_emsd(
yield portal
@asynccontextmanager
async def open_ems(
broker: str,
@ -248,4 +247,13 @@ async def open_ems(
with trio.fail_after(10):
await book._ready_to_receive.wait()
try:
yield book, trades_stream
finally:
# TODO: we want to eventually keep this up (by having
# the exec loop keep running in the pikerd tree) but for
# now we have to kill the context to avoid backpressure
# build-up on the shm write loop.
with trio.CancelScope(shield=True):
await trades_stream.aclose()