tractor/tractor
Tyler Goodlet 15a47dc4f7 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
2025-03-24 14:04:52 -04:00
..
_testing Start a new `._testing.fault_simulation` 2025-03-24 14:04:51 -04:00
devx Finally, officially support shielded REPL-ing! 2025-03-24 14:04:52 -04:00
experimental Drop now-deprecated deps on modern `trio`/Python 2025-03-16 16:06:24 -04:00
msg Rename `PldRx.dec_msg()` -> `.decode_pld()` 2025-03-24 14:04:52 -04:00
trionics Drop now-deprecated deps on modern `trio`/Python 2025-03-16 16:06:24 -04:00
__init__.py Expose `tractor.current_ipc_ctx()` at pkg level 2025-03-24 14:04:51 -04:00
_child.py Hide `._entry`/`._child` frames, tweak some more type annots 2025-03-20 23:22:45 -04:00
_clustering.py Passthrough runtime kwargs from `open_actor_cluster()` 2022-12-11 19:56:08 -05:00
_context.py Add `from_src_exc: BaseException` to maybe raisers 2025-03-24 14:04:52 -04:00
_discovery.py More spaceless union type annots 2025-03-20 19:50:31 -04:00
_entry.py Call `.devx._debug.hide_runtime_frames()` by default 2025-03-24 14:04:51 -04:00
_exceptions.py Pass `boxed_type` from `_mk_msg_type_err()` 2025-03-24 14:04:52 -04:00
_forkserver_override.py Re-license code base for distribution under AGPL 2021-12-14 23:33:27 -05:00
_ipc.py Drop `msg.types.Msg` for new replacement types 2025-03-24 14:04:51 -04:00
_mp_fixup_main.py Avoid importing mp for as long as possible 2022-02-17 11:55:26 -05:00
_multiaddr.py Fix doc string "its" typo.. 2025-03-20 19:50:31 -04:00
_portal.py Adjust `Portal` usage of `Context.pld_rx` 2025-03-24 14:04:51 -04:00
_root.py Call `.devx._debug.hide_runtime_frames()` by default 2025-03-24 14:04:51 -04:00
_rpc.py Always `.exception()` in `try_ship_error_to_remote()` on internal error 2025-03-24 14:04:52 -04:00
_runtime.py Don't (noisly) log about runtime cancel RPC tasks 2025-03-24 14:04:51 -04:00
_spawn.py Add debug check-n-wait inside `._spawn.soft_kill()` 2025-03-24 14:04:51 -04:00
_state.py Add error suppress flag to `current_ipc_ctx()` 2025-03-24 14:04:51 -04:00
_streaming.py Pass `boxed_type` from `_mk_msg_type_err()` 2025-03-24 14:04:52 -04:00
_supervise.py Show runtime nursery frames on internal errors 2025-03-24 14:04:51 -04:00
log.py Bleh, make `log.devx()` level less then cancel but > `.runtime()` 2025-03-20 23:22:45 -04:00
to_asyncio.py Provision for infected-`asyncio` debug mode support 2025-03-20 22:37:51 -04:00