From 0ccf83d5200c7d40fe155208b8b2c9c6d99a3677 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 5 May 2025 16:03:03 -0400 Subject: [PATCH] Use `.is_debug_mode()` for maybe-crash-handling Such that the default is `None` and in the case where the caller *does not* set the `pdb` arg to an explicit `bool` we instead determine it via the output from `._state.is_debug_mode()` allowing for more "nonchalant" usage throughout a (test) code base which passes the `debug_mode: bool` as runtime config; allows delegation to the per-actor proc-global state. --- tractor/devx/_debug.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tractor/devx/_debug.py b/tractor/devx/_debug.py index 67695feb..254966f1 100644 --- a/tractor/devx/_debug.py +++ b/tractor/devx/_debug.py @@ -3280,7 +3280,7 @@ def open_crash_handler( @cm def maybe_open_crash_handler( - pdb: bool = False, + pdb: bool|None = None, tb_hide: bool = True, **kwargs, @@ -3291,7 +3291,11 @@ def maybe_open_crash_handler( Normally this is used with CLI endpoints such that if the --pdb flag is passed the pdb REPL is engaed on any crashes B) + ''' + if pdb is None: + pdb: bool = _state.is_debug_mode() + __tracebackhide__: bool = tb_hide rtctx = nullcontext(