From 1cc33abca0426fbb826fe32390ee5ecc9f819688 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 24 Mar 2019 12:09:17 -0400 Subject: [PATCH] Don't bail when a sub-optschain crashes --- piker/ui/monitor.py | 24 +++++++++++++++--------- piker/ui/tabular.py | 7 ++++++- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/piker/ui/monitor.py b/piker/ui/monitor.py index 78f25bc1..7f8502e0 100644 --- a/piker/ui/monitor.py +++ b/piker/ui/monitor.py @@ -7,7 +7,6 @@ Launch with ``piker monitor ``. """ from types import ModuleType, AsyncGeneratorType from typing import List, Callable -from functools import partial import trio import tractor @@ -146,6 +145,8 @@ async def update_quotes( async def stream_symbol_selection(): """An RPC async gen for streaming the symbol corresponding value corresponding to the last clicked row. + + Essentially of an event stream of clicked symbol values. """ widgets = tractor.current_actor().statespace['widgets'] table = widgets['table'] @@ -235,14 +236,19 @@ async def _async_main( """ from .option_chain import _async_main - async with tractor.open_nursery() as tn: - await tn.run_in_actor( - 'optschain', - _async_main, - symbol=table.last_clicked_row._last_record['symbol'], - brokername=brokermod.name, - # loglevel=tractor.log.get_loglevel(), - ) + try: + async with tractor.open_nursery() as tn: + portal = await tn.run_in_actor( + 'optschain', + _async_main, + symbol=table.last_clicked_row._last_record['symbol'], + brokername=brokermod.name, + loglevel=tractor.log.get_loglevel(), + ) + except tractor.RemoteActorError: + # don't allow option chain errors to crash this monitor + # this is, like, the most basic of resliency policies + log.exception(f"{portal.actor.name} crashed:") async with trio.open_nursery() as nursery: pager = PagerView( diff --git a/piker/ui/tabular.py b/piker/ui/tabular.py index d1219b8e..d995848a 100644 --- a/piker/ui/tabular.py +++ b/piker/ui/tabular.py @@ -384,8 +384,13 @@ class Row(HoverBehavior, GridLayout): log.info(f"Pressed row for {self._last_record['symbol']}") if self.table and not self.is_header: self.table.last_clicked_row = self + symbol = self._last_record['symbol'] for sendchan in self.table._click_queues: - sendchan.send_nowait(self._last_record['symbol']) + try: + sendchan.send_nowait(symbol) + except trio.BrokenResourceError: + # indicates streaming client actor has terminated + log.warning("Symbol selection stream was already closed") class TickerTable(GridLayout):