From ffbfd187ada7febe0c967793c9a6f25820acfdf1 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 18 Aug 2021 15:15:28 -0400 Subject: [PATCH] Raise cache miss on a disconnected ib client --- piker/brokers/ib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/piker/brokers/ib.py b/piker/brokers/ib.py index 6abe257a..23e71a0b 100644 --- a/piker/brokers/ib.py +++ b/piker/brokers/ib.py @@ -701,6 +701,10 @@ async def _aio_get_client( # grab first cached client client = list(_client_cache.values())[0] + if not client.ib.isConnected(): + # we have a stale client to re-allocate + raise KeyError + yield client except (KeyError, IndexError): @@ -780,7 +784,6 @@ async def _aio_run_client_method( kwargs['to_trio'] = to_trio log.runtime(f'Running {meth}({kwargs})') - return await async_meth(**kwargs)