Compare commits

..

No commits in common. "d4dc8854e019ebf5b736c833b9db592bee2a68a8" and "ebc5bbd42be03632ee476eec18a2ca5eb4b8bc4a" have entirely different histories.

4 changed files with 30 additions and 57 deletions

View File

@ -37,7 +37,6 @@ except ModuleNotFoundError:
from tractor._exceptions import reg_err_types from tractor._exceptions import reg_err_types
from tractor.devx.pformat import ppfmt
from .log import get_logger from .log import get_logger
log = get_logger('broker-config') log = get_logger('broker-config')
@ -358,56 +357,30 @@ def write(
def load_accounts( def load_accounts(
providers: list[str]|None = None providers: list[str] | None = None
) -> bidict[str, str|None]:
) -> bidict[str, str | None]:
conf, path = load( conf, path = load(
conf_name='brokers', conf_name='brokers',
) )
accounts = bidict({ accounts = bidict()
# XXX, default paper-engine entry; this MUST be set. for provider_name, section in conf.items():
'paper': None, accounts_section = section.get('accounts')
})
msg: str = (
'Loading account(s) from `brokers.toml`,\n'
)
for (
provider_name,
section,
) in conf.items():
accounts_section: dict[str, str] = section.get('accounts')
if accounts_section is None:
msg += f'No accounts declared for {provider_name!r}?\n'
continue
# msg += f'Loaded accounts for {provider_name!r}?\n'
if ( if (
providers is None providers is None or
or ( providers and provider_name in providers
providers
and
provider_name in providers
)
): ):
for ( if accounts_section is None:
label, log.warning(f'No accounts named for {provider_name}?')
value, continue
) in accounts_section.items(): else:
account_alias: str = f'{provider_name}.{label}' for label, value in accounts_section.items():
accounts[account_alias] = value accounts[
msg += f'{account_alias} = {value!r}\n' f'{provider_name}.{label}'
] = value
else: # our default paper engine entry
log.debug( accounts['paper'] = None
f'NOT loading account(s) for entry in `brokers.toml`,\n'
f'The account provider was not requested for loading.\n'
f'requested-providers: {providers!r}\n'
f'this-provider: {provider_name!r}\n'
f'\n'
f'{ppfmt(accounts_section)}\n'
)
# ?TODO? mk this bp work?
# breakpoint()
log.info(msg)
return accounts return accounts

View File

@ -218,13 +218,11 @@ async def maybe_spawn_daemon(
lock.statistics().owner is current_task() lock.statistics().owner is current_task()
): ):
log.exception( log.exception(
f'Releasing stale lock after crash..?\n' f'Releasing stale lock after crash..?'
f'\n'
f'{err!r}\n' f'{err!r}\n'
) )
lock.release() lock.release()
raise err
raise
async def spawn_emsd( async def spawn_emsd(

View File

@ -131,11 +131,11 @@ async def _async_main(
async with ( async with (
tractor.trionics.collapse_eg(), tractor.trionics.collapse_eg(),
trio.open_nursery() as tn, trio.open_nursery() as root_n,
): ):
# set root nursery and task stack for spawning other charts/feeds # set root nursery and task stack for spawning other charts/feeds
# that run cached in the bg # that run cached in the bg
godwidget._root_n = tn godwidget._root_n = root_n
# setup search widget and focus main chart view at startup # setup search widget and focus main chart view at startup
# search widget is a singleton alongside the godwidget # search widget is a singleton alongside the godwidget
@ -165,7 +165,7 @@ async def _async_main(
# load other providers into search **after** # load other providers into search **after**
# the chart's select cache # the chart's select cache
for brokername, mod in needed_brokermods.items(): for brokername, mod in needed_brokermods.items():
tn.start_soon( root_n.start_soon(
load_provider_search, load_provider_search,
mod, mod,
loglevel, loglevel,

View File

@ -1346,6 +1346,7 @@ async def display_symbol_data(
fqmes, fqmes,
loglevel=loglevel, loglevel=loglevel,
tick_throttle=cycles_per_feed, tick_throttle=cycles_per_feed,
) as feed, ) as feed,
): ):
@ -1460,7 +1461,7 @@ async def display_symbol_data(
async with ( async with (
tractor.trionics.collapse_eg(), tractor.trionics.collapse_eg(),
trio.open_nursery() as tn, trio.open_nursery() as ln,
): ):
# if available load volume related built-in display(s) # if available load volume related built-in display(s)
vlm_charts: dict[ vlm_charts: dict[
@ -1471,7 +1472,7 @@ async def display_symbol_data(
flume.has_vlm() flume.has_vlm()
and vlm_chart is None and vlm_chart is None
): ):
vlm_chart = vlm_charts[fqme] = await tn.start( vlm_chart = vlm_charts[fqme] = await ln.start(
open_vlm_displays, open_vlm_displays,
rt_linked, rt_linked,
flume, flume,
@ -1479,7 +1480,7 @@ async def display_symbol_data(
# load (user's) FSP set (otherwise known as "indicators") # load (user's) FSP set (otherwise known as "indicators")
# from an input config. # from an input config.
tn.start_soon( ln.start_soon(
start_fsp_displays, start_fsp_displays,
rt_linked, rt_linked,
flume, flume,
@ -1603,11 +1604,11 @@ async def display_symbol_data(
# start update loop task # start update loop task
dss: dict[str, DisplayState] = {} dss: dict[str, DisplayState] = {}
tn.start_soon( ln.start_soon(
partial( partial(
graphics_update_loop, graphics_update_loop,
dss=dss, dss=dss,
nurse=tn, nurse=ln,
godwidget=godwidget, godwidget=godwidget,
feed=feed, feed=feed,
# min_istream, # min_istream,
@ -1622,6 +1623,7 @@ async def display_symbol_data(
order_ctl_fqme: str = fqmes[0] order_ctl_fqme: str = fqmes[0]
mode: OrderMode mode: OrderMode
async with ( async with (
open_order_mode( open_order_mode(
feed, feed,
godwidget, godwidget,