Alway teardown quote gen on exit
parent
78dced3091
commit
4753dc2db8
|
@ -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,38 +225,36 @@ 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,
|
contained=table,
|
||||||
contained=table,
|
nursery=nursery
|
||||||
nursery=nursery
|
)
|
||||||
)
|
box.add_widget(pager)
|
||||||
box.add_widget(pager)
|
|
||||||
|
|
||||||
widgets = {
|
|
||||||
'root': box,
|
|
||||||
'table': table,
|
|
||||||
'box': box,
|
|
||||||
'header': header,
|
|
||||||
'pager': pager,
|
|
||||||
}
|
|
||||||
ss['widgets'] = widgets
|
|
||||||
nursery.start_soon(
|
|
||||||
update_quotes,
|
|
||||||
nursery,
|
|
||||||
brokermod.format_stock_quote,
|
|
||||||
widgets,
|
|
||||||
quote_gen,
|
|
||||||
feed._symbol_data_cache,
|
|
||||||
quotes
|
|
||||||
)
|
|
||||||
|
|
||||||
|
widgets = {
|
||||||
|
'root': box,
|
||||||
|
'table': table,
|
||||||
|
'box': box,
|
||||||
|
'header': header,
|
||||||
|
'pager': pager,
|
||||||
|
}
|
||||||
|
ss['widgets'] = widgets
|
||||||
|
nursery.start_soon(
|
||||||
|
update_quotes,
|
||||||
|
nursery,
|
||||||
|
brokermod.format_stock_quote,
|
||||||
|
widgets,
|
||||||
|
quote_gen,
|
||||||
|
feed._symbol_data_cache,
|
||||||
|
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()
|
|
||||||
|
|
Loading…
Reference in New Issue