Cancel symbol unsub if brokerd is already down

kivy_mainline_and_py3.8
Tyler Goodlet 2018-07-06 17:26:24 -04:00
parent 6c977cfb7b
commit 4427e2869c
1 changed files with 67 additions and 65 deletions

View File

@ -371,7 +371,7 @@ async def update_quotes(
grid.render_rows(cache)
log.debug("Waiting on quotes")
log.warn("Server connection dropped")
log.warn("`brokerd` connection dropped")
nursery.cancel_scope.cancel()
@ -391,7 +391,6 @@ async def _async_main(name, portal, tickers, brokermod, rate):
"piker.brokers.core", 'start_quote_stream',
broker=brokermod.name, tickers=tickers)
try:
async with trio.open_nursery() as nursery:
# get first quotes response
log.debug("Waiting on first quote...")
@ -457,11 +456,14 @@ async def _async_main(name, portal, tickers, brokermod, rate):
nursery.start_soon(
update_quotes, nursery, brokermod, widgets, agen, sd, quotes)
try:
# Trio-kivy entry point.
await async_runTouchApp(widgets['root']) # run kivy
await agen.aclose() # cancel aysnc gen call
finally:
# un-subscribe from symbols stream
# un-subscribe from symbols stream (cancel if brokerd
# was already torn down - say by SIGINT)
with trio.move_on_after(0.2):
await portal.run(
"piker.brokers.core", 'modify_quote_stream',
broker=brokermod.name, tickers=[])