From e1be80e9e0da48933f95a3534ab77aaf27f56aef Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 11 Dec 2018 15:22:34 -0500 Subject: [PATCH] Subscription teardown is done server side on disconnect now --- piker/ui/monitor.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/piker/ui/monitor.py b/piker/ui/monitor.py index 9d15b257..de371c06 100644 --- a/piker/ui/monitor.py +++ b/piker/ui/monitor.py @@ -424,7 +424,7 @@ class TickerTable(GridLayout): symbol name. Most naive algo possible for the moment. """ for symbol, row in self.symbols2rows.items(): - if patt in symbol: + if patt in symbol: yield symbol, row def get_row(self, symbol: str) -> Row: @@ -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()