Cancel symbol unsub if brokerd is already down
parent
6c977cfb7b
commit
4427e2869c
|
@ -371,7 +371,7 @@ async def update_quotes(
|
||||||
grid.render_rows(cache)
|
grid.render_rows(cache)
|
||||||
log.debug("Waiting on quotes")
|
log.debug("Waiting on quotes")
|
||||||
|
|
||||||
log.warn("Server connection dropped")
|
log.warn("`brokerd` connection dropped")
|
||||||
nursery.cancel_scope.cancel()
|
nursery.cancel_scope.cancel()
|
||||||
|
|
||||||
|
|
||||||
|
@ -391,7 +391,6 @@ async def _async_main(name, portal, tickers, brokermod, rate):
|
||||||
"piker.brokers.core", 'start_quote_stream',
|
"piker.brokers.core", 'start_quote_stream',
|
||||||
broker=brokermod.name, tickers=tickers)
|
broker=brokermod.name, tickers=tickers)
|
||||||
|
|
||||||
try:
|
|
||||||
async with trio.open_nursery() as nursery:
|
async with trio.open_nursery() as nursery:
|
||||||
# get first quotes response
|
# get first quotes response
|
||||||
log.debug("Waiting on first quote...")
|
log.debug("Waiting on first quote...")
|
||||||
|
@ -457,11 +456,14 @@ async def _async_main(name, portal, tickers, brokermod, rate):
|
||||||
nursery.start_soon(
|
nursery.start_soon(
|
||||||
update_quotes, nursery, brokermod, widgets, agen, sd, quotes)
|
update_quotes, nursery, brokermod, widgets, agen, sd, quotes)
|
||||||
|
|
||||||
|
try:
|
||||||
# Trio-kivy entry point.
|
# Trio-kivy entry point.
|
||||||
await async_runTouchApp(widgets['root']) # run kivy
|
await async_runTouchApp(widgets['root']) # run kivy
|
||||||
await agen.aclose() # cancel aysnc gen call
|
await agen.aclose() # cancel aysnc gen call
|
||||||
finally:
|
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(
|
await portal.run(
|
||||||
"piker.brokers.core", 'modify_quote_stream',
|
"piker.brokers.core", 'modify_quote_stream',
|
||||||
broker=brokermod.name, tickers=[])
|
broker=brokermod.name, tickers=[])
|
||||||
|
|
Loading…
Reference in New Issue