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-codetpt_tolerance
parent
7145fa364f
commit
5ded99a886
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue