tractor/tractor
Tyler Goodlet 9167fbb0a8 Much more limited `asyncio.Task.cancel()` use
Since it can not only cause the guest-mode run to abandon but also in
some edge cases prevent `trio`-errors from propagating (at least on
py3.12-13?) as discovered as part of supporting this mode officially
in the *root actor*.

As such try to avoid that method as much as possible instead opting to
pass the `trio`-side error via the iter-task channel ref.

Deats,
- add a `LinkedTaskChannel._trio_err: BaseException|None` which gets set
  whenver the `trio.Task` error is caught; ONLY set `AsyncioCancelled`
  when the `trio` task was for sure the cause, whether itself cancelled
  or errored.
- always check for this error when exiting the `asyncio` side (even when
  terminated via a call to `asyncio.Task.cancel()` or during any other
  `CancelledError` handling such that the `asyncio`-task can expect to
  handle `AsyncioCancelled` due to the above^^ cases.
- never `cs.cancel()` the `trio` side unless that cancel scope has not
  yet been `.cancel_called` whatsoever; it's a noop anyway.
- only raise any exc from `asyncio.Task.result()` when `chan._aio_err`
  does not already match it since the existence of the pre-existing
  `task_err` means `asyncio` prolly intends (or has already) raised and
  interrupted the task elsewhere.

Various supporting tweaks,
- don't bother maybe-init-ing `greenback` from the actor entrypoint
  since we already need to (and do) bestow the portals to each `asyncio`
  task spawned using the `run_task()`/`open_channel_from()` API; further
  the init-ing should be done already by client code that enables
  infected mode (even in the root actor).
 |_we should prolly also codify it from any
   `run_daemon(infected_aio=True, debug_mode=True)` usage we offer.
- pass all the `_<field>`s to `Linked TaskChannel` explicitly in named
  kwarg style.
- better sclang-style log reports throughout, particularly on teardowns.
- generally more/better comments and docs around (not well understood)
  edge cases.
- prep to just inline `maybe_raise_aio_side_err()` closure..
2025-03-10 12:04:51 -04:00
..
_testing Move `mk_cmd()` to `._testing` 2024-07-10 15:40:44 -04:00
devx Drop extra nl from boxed error fmt 2025-03-10 12:04:51 -04:00
experimental Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00
msg Draft a (pretty)`Struct.fields_diff()` 2024-12-10 14:12:37 -05:00
trionics Change masked `.pause()` line 2024-12-09 18:04:32 -05:00
__init__.py Finally implement peer-lookup optimization.. 2024-07-04 19:40:11 -04:00
_child.py Hide `._entry`/`._child` frames, tweak some more type annots 2024-04-14 17:49:18 -04:00
_clustering.py Passthrough runtime kwargs from `open_actor_cluster()` 2022-12-11 19:56:08 -05:00
_context.py Change masked `.pause()` line 2024-12-09 18:04:32 -05:00
_discovery.py Finally implement peer-lookup optimization.. 2024-07-04 19:40:11 -04:00
_entry.py Pass `infect_asyncio` setting via runtime-vars 2024-07-11 13:22:53 -04:00
_exceptions.py Accept err-type override in `is_multi_cancelled()` 2025-03-10 12:04:51 -04:00
_forkserver_override.py Re-license code base for distribution under AGPL 2021-12-14 23:33:27 -05:00
_ipc.py More formal `TransportClosed` reporting/raising 2024-07-02 12:21:26 -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.. 2023-11-06 15:44:21 -05:00
_portal.py More-n-more scops annots in logging 2024-07-04 15:06:15 -04:00
_root.py Expose `debug_filter` from `open_root_actor()` also 2025-03-10 12:04:51 -04:00
_rpc.py More formal `TransportClosed` reporting/raising 2024-07-02 12:21:26 -04:00
_runtime.py Denoise duplicate chan logging for now 2024-12-09 17:36:52 -05:00
_shm.py Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00
_spawn.py Use `._entry` proto-ed "lifetime ops" in logging 2024-07-02 16:31:58 -04:00
_state.py Pass `infect_asyncio` setting via runtime-vars 2024-07-11 13:22:53 -04:00
_streaming.py Reraise RAEs in `MsgStream.receive()`; truncate tbs 2024-07-02 16:31:15 -04:00
_supervise.py Add `tb_hide: bool` ctl flag to `_open_and_supervise_one_cancels_all_nursery()` 2024-08-22 17:22:53 -04:00
log.py Support passing pre-conf-ed `Logger` 2025-03-10 12:04:51 -04:00
to_asyncio.py Much more limited `asyncio.Task.cancel()` use 2025-03-10 12:04:51 -04:00