tractor/examples/debugging
Tyler Goodlet 8ea0f08386 Finally, officially support shielded REPL-ing!
It's been a long time prepped and now finally implemented!

Offer a `shield: bool` argument from our async `._debug` APIs:
- `await tractor.pause(shield=True)`,
- `await tractor.post_mortem(shield=True)`

^-These-^ can now be used inside cancelled `trio.CancelScope`s,
something very handy when introspecting complex (distributed) system
tear/shut-downs particularly under remote error or (inter-peer)
cancellation conditions B)

Thanks to previous prepping in a prior attempt and various patches from
the rigorous rework of `.devx._debug` internals around typed msg specs,
there ain't much that was needed!

Impl deats
- obvi passthrough `shield` from the public API endpoints (was already
  done from a prior attempt).
- put ad-hoc internal `with trio.CancelScope(shield=shield):` around all
  checkpoints inside `._pause()` for both the root-process and subactor
  case branches.

Add a fairly rigorous example, `examples/debugging/shielded_pause.py`
with a wrapping `pexpect` test, `test_debugger.test_shield_pause()` and
ensure it covers as many cases as i can think of offhand:

- multiple `.pause()` entries in a loop despite parent scope
  cancellation in a subactor RPC task which itself spawns a sub-task.
- a `trio.Nursery.parent_task` which raises, is handled and
  tries to enter and unshielded `.post_mortem()`, which of course
  internally raises `Cancelled` in a `._pause()` checkpoint, so we catch
  the `Cancelled` again and then debug the debugger's internal
  cancellation with specific checks for the particular raising
  checkpoint-LOC.
- do ^- the latter -^ for both subactor and root cases to ensure we
  can debug `._pause()` itself when it tries to REPL engage from
  a cancelled task scope Bo
2024-05-30 17:52:24 -04:00
..
asyncio_bp.py Provision for infected-`asyncio` debug mode support 2024-03-25 16:09:32 -04:00
debug_mode_hang.py Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00
fast_error_in_root_after_spawn.py Fix type path to new `_supervise` mod 2021-10-23 15:54:40 -04:00
multi_daemon_subactors.py Tweaks to debugger examples 2024-05-28 09:22:59 -04:00
multi_nested_subactors_error_up_through_nurseries.py Tweaks to debugger examples 2024-05-28 09:22:59 -04:00
multi_subactor_root_errors.py Adjust debugger tests to expect depth > 1 crashes 2021-10-14 13:39:46 -04:00
multi_subactors.py Flip to `.pause()` in subactor bp example 2024-04-14 18:53:42 -04:00
open_ctx_modnofound.py Add basic module-not-found when opening a ctx eg. 2022-08-02 12:17:06 -04:00
per_actor_debug.py Tweaks to debugger examples 2024-05-28 09:22:59 -04:00
pm_in_subactor.py Add a `tractor.post_mortem()` API test + example 2024-05-30 16:03:28 -04:00
restore_builtin_breakpoint.py Restore `breakpoint()` hook after runtime exits 2023-05-15 00:47:29 -04:00
root_actor_breakpoint.py Drop `tractor.run()` from all examples 2021-05-07 11:21:40 -04:00
root_actor_breakpoint_forever.py Tweaks to debugger examples 2024-05-28 09:22:59 -04:00
root_actor_error.py Drop `tractor.run()` from all examples 2021-05-07 11:21:40 -04:00
root_cancelled_but_child_is_in_tty_lock.py Drop `tractor.run()` from all examples 2021-05-07 11:21:40 -04:00
root_timeout_while_child_crashed.py Docs and comments tidying 2021-08-01 10:44:13 -04:00
shielded_pause.py Finally, officially support shielded REPL-ing! 2024-05-30 17:52:24 -04:00
subactor_bp_in_ctx.py Add back in async gen loop 2022-07-27 11:40:02 -04:00
subactor_breakpoint.py Flip to `.pause()` in subactor bp example 2024-04-14 18:53:42 -04:00
subactor_error.py Tweaks to debugger examples 2024-05-28 09:22:59 -04:00
sync_bp.py Tweaks to debugger examples 2024-05-28 09:22:59 -04:00