From 78b9333bcd371789e2c83dd98a7f653c10cb720d Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 5 Jun 2022 16:49:30 -0400 Subject: [PATCH] Expect `list` of ports in `ib.ports` section Given that naming the port map is mostly pointless, since accounts can be detected once the client connects, just expect a `brokers.toml` to define a simple sequence of port numbers. Toss in a warning for using the old map/`dict` style. --- piker/brokers/ib.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/piker/brokers/ib.py b/piker/brokers/ib.py index ab22f4d6..bfb78697 100644 --- a/piker/brokers/ib.py +++ b/piker/brokers/ib.py @@ -883,14 +883,7 @@ async def recv_trade_updates( # let the engine run and stream await client.ib.disconnectedEvent - -# default config ports -_tws_port: int = 7497 -_gw_port: int = 4002 -_try_ports = [ - _gw_port, - _tws_port -] +# per-actor API ep caching _client_cache: dict[tuple[str, int], Client] = {} _scan_ignore: set[tuple[str, int]] = set() @@ -951,22 +944,20 @@ async def load_aio_clients( raise ValueError( 'Specify only one of `host` or `hosts` in `brokers.toml` config') - ports = conf.get( + try_ports = conf.get( 'ports', # default order is to check for gw first - { - 'gw': 4002, - 'tws': 7497, - } + [4002, 7497,] ) - order = ports.pop('order', None) - if order: - log.warning('`ports.order` section in `brokers.toml` is deprecated') + if isinstance(try_ports, dict): + log.warning( + '`ib.ports` in `brokers.toml` should be a `list` NOT a `dict`' + ) + try_ports = list(ports.values()) _err = None accounts_def = config.load_accounts(['ib']) - try_ports = list(ports.values()) ports = try_ports if port is None else [port] combos = list(itertools.product(hosts, ports)) accounts_found: dict[str, Client] = {}