Always do symbol unsubscribe on teardown

kivy_mainline_and_py3.8
Tyler Goodlet 2018-07-05 15:31:52 -04:00
parent 73eedfd7b3
commit f4a91a4975
1 changed files with 62 additions and 59 deletions

View File

@ -391,6 +391,7 @@ 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...")
@ -459,6 +460,8 @@ async def _async_main(name, portal, tickers, brokermod, rate):
# 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:
# un-subscribe from symbols stream
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=[])