Subscription teardown is done server side on disconnect now

kivy_mainline_and_py3.8
Tyler Goodlet 2018-12-11 15:22:34 -05:00
parent e7378538f6
commit e1be80e9e0
1 changed files with 10 additions and 15 deletions

View File

@ -546,7 +546,7 @@ async def _async_main(
portal: tractor._portal.Portal,
tickers: List[str],
brokermod: ModuleType,
rate: int,
rate: int = 3,
test: bool = False
) -> None:
'''Launch kivy app + all other related tasks.
@ -565,8 +565,12 @@ async def _async_main(
else:
# start live streaming from broker daemon
quote_gen = await portal.run(
"piker.brokers.data", 'start_quote_stream',
broker=brokermod.name, symbols=tickers)
"piker.brokers.data",
'start_quote_stream',
broker=brokermod.name,
symbols=tickers,
rate=3,
)
# subscribe for tickers (this performs a possible filtering
# where invalid symbols are discarded)
@ -657,16 +661,7 @@ async def _async_main(
# Trio-kivy entry point.
await async_runTouchApp(widgets['root']) # run kivy
finally:
await quote_gen.aclose() # cancel aysnc gen call
# 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.data", 'modify_quote_stream',
broker=brokermod.name,
feed_type='stock',
symbols=[]
)
# cancel aysnc gen call
await quote_gen.aclose()
# cancel GUI update task
nursery.cancel_scope.cancel()