forked from goodboy/tractor
1
0
Fork 0
tractor/tractor
Tyler Goodlet 0c6d512ba4 Solve another OoB cancellation case, the bg task one
Such that we are able to (finally) detect when we should
`Context._scope.cancel()` specifically when the `.parent_task` is
**not** blocking on receiving from the underlying `._rx_chan`, since if
the task is blocking on `.receive()` it will call `.cancel()`
implicitly.

This is a lot to explain with very little code actually needed for the
implementation (are we like `trio` yet anyone?? XD) but the main jist is
that `Context._maybe_cancel_and_set_remote_error()` needed the
additional case of calling `._scope.cancel()` whenever we know that
a remote-error/ctxc won't be immediately handled, bc user code is doing
non `Context`-API things, and result in a similar outcome as if that
task was waiting on `Context.wait_for_result()` or `.__aexite__()`.

Impl details,
- add a new `._is_blocked_on_rx_chan()` method which predicates whether
  the (new) `.parent_task` is blocking on `._rx_chan.receive()`.
  * see various stipulations about the current impl and how we might
    need to adjust for the future given `trio`'s commitment to the
    `Task.custom_sleep_data` attr..
- add `.parent_task`, a pub wrapper for `._task`.
- check for `not ._is_blocked_on_rx_chan()` before manually cancelling
  the local `.parent_task`
- minimize the surrounding branch case expressions.

Other,
- tweak a couple logs.
- add a new `.cancel()` pre-started msg.
- mask the `.cancel_called` setter, it's only (been) used for tracing.
- todos around maybe moving the `._nursery` allocation "around" the
  `.start_remote_task()` call and various subsequent tweaks therein.
2025-09-11 13:12:52 -04:00
..
_testing Mk `.devx._debug` a sub-pkg `.devx.debug` 2025-07-14 00:00:12 -04:00
devx Heh, add back `Actor._root_tn`, it has purpose.. 2025-08-20 10:18:52 -04:00
experimental Add API-modernize-todo on `experimental._pubsub.fan_out_to_ctxs` 2025-07-08 18:05:05 -04:00
ipc Always pass a `tn` to `._server._serve_ipc_eps()` 2025-08-20 11:30:58 -04:00
msg Check off REPL-ing todo add masked usage in `drain_to_final_msg()` 2025-09-11 10:13:04 -04:00
trionics Tweaks from copilot, type fix, typos, language. 2025-09-11 10:01:25 -04:00
__init__.py move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
_addr.py Move concrete `Address`es to each tpt module 2025-07-08 18:05:05 -04:00
_child.py Adjust `._child` instantiation of `Actor` to use newly named `uuid` arg 2025-07-08 12:57:28 -04:00
_clustering.py Fix cluster suite, chng to new `gather_contexts()` 2025-08-18 10:46:37 -04:00
_context.py Solve another OoB cancellation case, the bg task one 2025-09-11 13:12:52 -04:00
_discovery.py Switch to strict-eg nurseries almost everywhere 2025-08-18 10:46:37 -04:00
_entry.py Drop `actor_info: str` from `._entry` logs 2025-08-15 16:24:06 -04:00
_exceptions.py Move `.is_multi_cancelled()` to `.trioniics._beg` 2025-07-16 15:49:18 -04:00
_forkserver_override.py Re-license code base for distribution under AGPL 2021-12-14 23:33:27 -05: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 Set `Channel._cancel_called` via `chan` var 2025-08-18 21:30:48 -04:00
_root.py Hide `collapse_eg()` frame as used from `open_root_actor()` 2025-08-20 10:44:42 -04:00
_rpc.py Drop `tn` arg to `maybe_raise_from_masking_exc()` in `._rpc` 2025-08-20 12:45:49 -04:00
_runtime.py Comment/docs tweaks per copilot reivew 2025-08-20 12:36:08 -04:00
_spawn.py Add attempt at non-root-parent REPL guarding 2025-08-19 14:15:14 -04:00
_state.py Add initial `repl_fixture` support B) 2025-07-14 00:00:12 -04:00
_streaming.py Mk `.devx._debug` a sub-pkg `.devx.debug` 2025-07-14 00:00:12 -04:00
_supervise.py Rename var for and hide the `_open_and_supervise_one_cancels_all_nursery` frame 2025-09-11 10:13:04 -04:00
log.py .log: expose `at_least_level()` as `StackLevelAdapter` meth 2025-08-15 17:29:22 -04:00
to_asyncio.py Comment tweaks per copilot review 2025-08-19 12:33:47 -04:00