From 5ded99a886681272d7298b75f898cc141a27c9c0 Mon Sep 17 00:00:00 2001 From: goodboy Date: Wed, 18 Feb 2026 19:27:49 -0500 Subject: [PATCH] Add a `._trace.maybe_pause_bp()` for tpt-broken cases Internal helper which falls back to sync `pdb` when the child actor can't reach root to acquire the TTY lock. Useful when debugging tpt layer failures (intentional or otherwise) where a sub-actor can no longer IPC-contact the root to coordinate REPL access; root uses `.pause()` as normal while non-root falls back to `mk_pdb().set_trace()`. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tractor/devx/debug/_trace.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tractor/devx/debug/_trace.py b/tractor/devx/debug/_trace.py index c1219c30..84608671 100644 --- a/tractor/devx/debug/_trace.py +++ b/tractor/devx/debug/_trace.py @@ -1257,3 +1257,26 @@ async def breakpoint( api_frame=inspect.currentframe(), **kwargs, ) + + +async def maybe_pause_bp(): + ''' + Internal (ONLY for now) `breakpoint()`-er fn which only tries to + use the multi-actor `.pause()` API when the current actor is the + root. + + ?! BUT WHY !? + ------- + + This is useful when debugging cases where the tpt layer breaks + (or is intentionally broken, say during resiliency testing) in + the case where a child can no longer contact the root process to + acquire the process-tree-singleton TTY lock. + + ''' + import tractor + actor = tractor.current_actor() + if actor.aid.name == 'root': + await tractor.pause(shield=True) + else: + tractor.devx.mk_pdb().set_trace()