From f2ae3b0e2e4b1ec482751281c9cd21c490f3b2c4 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 29 Sep 2025 15:14:35 -0400 Subject: [PATCH] `accouning.calc`: enable crash handlers on `debug_mode` input (via test harness) --- piker/accounting/calc.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/piker/accounting/calc.py b/piker/accounting/calc.py index f57a2b3b..c60ed3dd 100644 --- a/piker/accounting/calc.py +++ b/piker/accounting/calc.py @@ -32,6 +32,7 @@ from typing import ( TYPE_CHECKING, ) +from tractor.devx import maybe_open_crash_handler import polars as pl from pendulum import ( DateTime, @@ -290,15 +291,13 @@ def iter_by_dt( # XXX: should never get here.. else: - if debug: - import tractor - with tractor.devx.maybe_open_crash_handler(): - raise ValueError( - f'Invalid txn time ??\n' - f'txn-id: {k!r}\n' - f'{k!r}: {v!r}\n' - ) - # assert v is not None, f'No valid value for `{k}`!?' + with maybe_open_crash_handler(pdb=True): + raise ValueError( + f'Invalid txn time ??\n' + f'txn-id: {k!r}\n' + f'{k!r}: {v!r}\n' + ) + # assert v is not None, f'No valid value for `{k}`!?' if _invalid is not None: _invalid.append(tx) @@ -386,6 +385,7 @@ def open_ledger_dfs( acctname: str, ledger: TransactionLedger | None = None, + debug_mode: bool = False, **kwargs, @@ -400,8 +400,7 @@ def open_ledger_dfs( can update the ledger on exit. ''' - from piker.toolz import open_crash_handler - with open_crash_handler(): + with maybe_open_crash_handler(pdb=debug_mode): if not ledger: import time from ._ledger import open_trade_ledger