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

@ -424,7 +424,7 @@ class TickerTable(GridLayout):
symbol name. Most naive algo possible for the moment. symbol name. Most naive algo possible for the moment.
""" """
for symbol, row in self.symbols2rows.items(): for symbol, row in self.symbols2rows.items():
if patt in symbol: if patt in symbol:
yield symbol, row yield symbol, row
def get_row(self, symbol: str) -> Row: def get_row(self, symbol: str) -> Row:
@ -546,7 +546,7 @@ async def _async_main(
portal: tractor._portal.Portal, portal: tractor._portal.Portal,
tickers: List[str], tickers: List[str],
brokermod: ModuleType, brokermod: ModuleType,
rate: int, rate: int = 3,
test: bool = False test: bool = False
) -> None: ) -> None:
'''Launch kivy app + all other related tasks. '''Launch kivy app + all other related tasks.
@ -565,8 +565,12 @@ async def _async_main(
else: else:
# start live streaming from broker daemon # start live streaming from broker daemon
quote_gen = await portal.run( quote_gen = await portal.run(
"piker.brokers.data", 'start_quote_stream', "piker.brokers.data",
broker=brokermod.name, symbols=tickers) 'start_quote_stream',
broker=brokermod.name,
symbols=tickers,
rate=3,
)
# subscribe for tickers (this performs a possible filtering # subscribe for tickers (this performs a possible filtering
# where invalid symbols are discarded) # where invalid symbols are discarded)
@ -657,16 +661,7 @@ async def _async_main(
# Trio-kivy entry point. # Trio-kivy entry point.
await async_runTouchApp(widgets['root']) # run kivy await async_runTouchApp(widgets['root']) # run kivy
finally: finally:
await quote_gen.aclose() # cancel aysnc gen call # cancel aysnc gen call
# un-subscribe from symbols stream (cancel if brokerd await quote_gen.aclose()
# 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 GUI update task # cancel GUI update task
nursery.cancel_scope.cancel() nursery.cancel_scope.cancel()