Compare commits

...

3 Commits

Author SHA1 Message Date
Gud Boi d4dc8854e0 Use `tn` for nursery vars in UI modules
Rename `root_n` -> `tn` in `_app.py` and
`ln` -> `tn` in `_display.py` to match the `trio` nursery naming
convention used elsewhere. Drop a couple stray blank lines.

(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
2026-04-01 14:05:08 -04:00
Gud Boi a0586f8219 Always re-raise in `maybe_spawn_daemon()` handler
Move bare `raise` outside the `if lock.owner` guard so the error
propagates regardless of whether the stale-lock branch runs. Also add
a blank-line separator in the crash log msg.

(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
2026-03-31 19:43:27 -04:00
Gud Boi 923b4de296 Improve `load_accounts()` logging and defaults
Move `'paper'` default entry into the initial `bidict` instead of
appending post-loop. Add per-provider branch logging: an `info`-level
msg accumulating each loaded `account_alias` and a `debug`-level msg
(using `ppfmt()`) when a provider is skipped bc it wasn't requested.

Also,
- Early-`continue` when `accounts_section is None` instead of nesting
  inside an `else`.
- Import `ppfmt` from `tractor.devx.pformat`.
- Tighten union-type annotations to `X|Y` style.
- De-structure loop vars for readability.

(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
2026-03-31 14:16:40 -04:00
4 changed files with 57 additions and 30 deletions

View File

@ -37,6 +37,7 @@ except ModuleNotFoundError:
from tractor._exceptions import reg_err_types
from tractor.devx.pformat import ppfmt
from .log import get_logger
log = get_logger('broker-config')
@ -357,30 +358,56 @@ def write(
def load_accounts(
providers: list[str] | None = None
) -> bidict[str, str | None]:
providers: list[str]|None = None
) -> bidict[str, str|None]:
conf, path = load(
conf_name='brokers',
)
accounts = bidict()
for provider_name, section in conf.items():
accounts_section = section.get('accounts')
accounts = bidict({
# XXX, default paper-engine entry; this MUST be set.
'paper': None,
})
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 (
providers is None or
providers and provider_name in providers
providers is None
or (
providers
and
provider_name in providers
)
):
if accounts_section is None:
log.warning(f'No accounts named for {provider_name}?')
continue
else:
for label, value in accounts_section.items():
accounts[
f'{provider_name}.{label}'
] = value
for (
label,
value,
) in accounts_section.items():
account_alias: str = f'{provider_name}.{label}'
accounts[account_alias] = value
msg += f'{account_alias} = {value!r}\n'
# our default paper engine entry
accounts['paper'] = None
else:
log.debug(
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

View File

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

View File

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

View File

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