tractor/tests
Tyler Goodlet d6a0c515ec Add per-side graceful-exit/cancel excs-as-signals
Such that any combination of task terminations/exits can be explicitly
handled and "dual side independent" crash cases re-raised in egs.

The main error-or-exit impl changes include,

- use of new per-side "signaling exceptions":
  - TrioTaskExited|TrioCancelled for signalling aio.
  - AsyncioTaskExited|AsyncioCancelled for signalling trio.

- NOT overloading the `LinkedTaskChannel._trio/aio_err` fields for
  err-as-signal relay and instead add a new pair of
  `._trio/aio_to_raise` maybe-exc-attrs which allow each side's
  task to specify what it would want the other side to raise to signal
  its/a termination outcome:
  - `._trio_to_raise: AsyncioTaskExited|AsyncioCancelled` to signal,
    |_ the aio task having returned while the trio side was still reading
       from the `asyncio.Queue` or is just not `.done()`.
    |_ the aio task being self or trio-request cancelled where
       a `asyncio.CancelledError` is raised and caught but NOT relayed
       as is back to trio; instead signal a "more explicit" exc type.
  - `._aio_to_raise: TrioTaskExited|TrioCancelled` to signal,
    |_ the trio task having returned while the aio side was still reading
       from the mem chan and indicating that the trio side might not
       care any more about future streamed values (like the
       `Stop/EndOfChannel` equivs for ipc `Context`s).
    |_ when the trio task canceld we do
        a `asyncio.Future.set_exception(TrioTaskExited())` to indicate
        to the aio side verbosely that it should cancel due to the trio
        parent.
  - `_aio/trio_err` are now left to only capturing the **actual**
    per-side task excs for introspection / other side's handling logic.

- supporting "graceful exits" depending on API in use from
  `translate_aio_errors()` such that if either side exits but the other
  side isn't expect to consume the final `return`ed value, we just exit
  silently, which required:
  - adding a `suppress_graceful_exits: bool` flag.
  - adjusting the `maybe_raise_aio_side_err()` logic to use that flag
    and suppress only on certain combos of `._trio_to_raise/._trio_err`.
  - prefer to raise `._trio_to_raise` when the aio-side is the src and
    vice versa.

- filling out pedantic logging for cancellation cases indicating which
  side is the cause.

- add a `LinkedTaskChannel._aio_result` modelled after our
  `Context._result` a a similar `.wait_for_result()` interface which
  allows maybe accessing the aio task's final return value if desired
  when using the `open_channel_from()` API.

- rename `cancel_trio()` done handler -> `signal_trio_when_done()`

Also some fairly major test suite updates,
- add a `delay: int` producing fixture which delivers a much larger
  timeout whenever `debug_mode` is set so that the REPL can be used
  without a surrounding cancel firing.
- add a new `test_aio_exits_early_relays_AsyncioTaskExited` including
  a paired `exit_early: bool` flag to `push_from_aio_task()`.
- adjust `test_trio_closes_early_causes_aio_checkpoint_raise` to expect
  a `to_asyncio.TrioTaskExited`.
2025-03-10 12:17:53 -04:00
..
devx Unset `$PYTHON_COLORS` for test debugger suite.. 2025-03-10 12:17:53 -04:00
conftest.py Draft test-doc for "out-of-band" `asyncio.Task`.. 2025-03-10 12:14:40 -04:00
test_2way.py Move context-streaming operational tests into one mod 2021-12-06 16:45:44 -05:00
test_advanced_faults.py Adjusts advanced fault tests to match new `TransportClosed` semantics 2024-07-05 13:31:29 -04:00
test_advanced_streaming.py Tweak some tests for spurious failues 2024-03-11 10:37:34 -04:00
test_cancellation.py Tweak some test asserts to better `is` style 2025-03-10 12:17:53 -04:00
test_caps_based_msging.py (Re)type annot some tests 2024-06-28 19:24:03 -04:00
test_child_manages_service_nursery.py Another loose-egs flag in `test_child_manages_service_nursery` 2025-03-10 12:17:53 -04:00
test_clustering.py Add (back) a `tractor._testing` sub-pkg 2024-03-13 09:09:08 -04:00
test_context_stream_semantics.py Change `tractor.breakpoint()` to new `.pause()` in test suite 2024-12-09 16:08:55 -05:00
test_discovery.py Finally implement peer-lookup optimization.. 2024-07-04 19:40:11 -04:00
test_docs_examples.py (Re)type annot some tests 2024-06-28 19:24:03 -04:00
test_infected_asyncio.py Add per-side graceful-exit/cancel excs-as-signals 2025-03-10 12:17:53 -04:00
test_inter_peer_cancellation.py Another `is` fix.. 2025-03-10 12:17:53 -04:00
test_legacy_one_way_streaming.py Flip a last `MultiError` to a beg, add todo on `@stream` func 2024-04-14 19:39:57 -04:00
test_local.py Finally implement peer-lookup optimization.. 2024-07-04 19:40:11 -04:00
test_multi_program.py Finally implement peer-lookup optimization.. 2024-07-04 19:40:11 -04:00
test_pldrx_limiting.py Update `MsgTypeError` content matching to latest 2024-06-28 14:46:29 -04:00
test_pubsub.py Add (back) a `tractor._testing` sub-pkg 2024-03-13 09:09:08 -04:00
test_resource_cache.py Bump timeout on resource cache test a bitty bit. 2024-01-03 22:27:05 -05:00
test_root_infect_asyncio.py Add a `tests/test_root_infect_asyncio` 2025-03-10 12:04:51 -04:00
test_rpc.py Adjust all `RemoteActorError.type` using tests 2024-03-19 18:08:54 -04:00
test_runtime.py Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00
test_shm.py Pass `str` dtype for `use_str` case 2023-06-15 12:20:20 -04:00
test_spawning.py Update tests for `PldRx` and `Context` changes 2024-05-09 16:48:53 -04:00
test_task_broadcasting.py Change `tractor.breakpoint()` to new `.pause()` in test suite 2024-12-09 16:08:55 -05:00
test_trioisms.py Impl a proto "unmasker" `@acm` alongside our test 2025-03-10 12:04:51 -04:00