Alway teardown quote gen on exit

kivy_mainline_and_py3.8
Tyler Goodlet 2019-01-14 21:12:35 -05:00
parent 78dced3091
commit 4753dc2db8
1 changed files with 28 additions and 32 deletions

View File

@ -140,8 +140,6 @@ async def update_quotes(
log.debug("Waiting on quotes") log.debug("Waiting on quotes")
log.warn("Data feed connection dropped") log.warn("Data feed connection dropped")
# XXX: if we're cancelled this should never get called
# nursery.cancel_scope.cancel()
async def stream_symbol_selection(): async def stream_symbol_selection():
@ -227,7 +225,6 @@ async def _async_main(
table.bind(minimum_height=table.setter('height')) table.bind(minimum_height=table.setter('height'))
ss = tractor.current_actor().statespace ss = tractor.current_actor().statespace
try:
async with trio.open_nursery() as nursery: async with trio.open_nursery() as nursery:
pager = PagerView( pager = PagerView(
container=box, container=box,
@ -253,12 +250,11 @@ async def _async_main(
feed._symbol_data_cache, feed._symbol_data_cache,
quotes quotes
) )
try:
# Trio-kivy entry point. # Trio-kivy entry point.
await async_runTouchApp(widgets['root']) # run kivy await async_runTouchApp(widgets['root']) # run kivy
finally:
# cancel remote data feed task
await quote_gen.aclose()
# cancel GUI update task # cancel GUI update task
nursery.cancel_scope.cancel() nursery.cancel_scope.cancel()
finally:
with trio.open_cancel_scope(shield=True):
# cancel aysnc gen call
await quote_gen.aclose()