forked from goodboy/tractor
1
0
Fork 0
tractor/tractor
Tyler Goodlet fa7e37d6ed (Event) more pedantic `.cancel_acked: bool` def
Changes the condition logic to be more strict and moves it to a private
`._is_self_cancelled() -> bool` predicate which can be used elsewhere
(instead of having almost similar duplicate checks all over the
place..) and allows taking in a specific `remote_error` just for
verification purposes (like for tests).

Main strictness distinctions are now:
- obvi that `.cancel_called` is set (this filters any
  `Portal.cancel_actor()` or other out-of-band RPC),
- the received `ContextCancelled` **must** have its `.canceller` set to
  this side's `Actor.uid` (indicating we are the requester).
- `.src_actor_uid` **must** be the same as the `.chan.uid` (so the error
  must have originated from the opposite side's task.
- `ContextCancelled.canceller` should be already set to the `.chan.uid`
  indicating we received the msg via the runtime calling
  `._deliver_msg()` -> `_maybe_cancel_and_set_remote_error()` which
  ensures the error is specifically destined for this ctx-task exactly
  the same as how `Actor._cancel_task()` sets it from an input
  `requesting_uid` arg.

In support of the above adjust some impl deats:
- add `Context._actor: Actor` which is set once in `mk_context()` to
  avoid issues (particularly in testing) where `current_actor()` raises
  after the root actor / runtime is already exited. Use `._actor.uid` in
  both `.cancel_acked` (obvi) and '_maybe_cancel_and_set_remote_error()`
  when deciding whether to call `._scope.cancel()`.
- always cast `.canceller` to `tuple` if not null.
- delegate `.cancel_acked` directly to new private predicate (obvi).
- always set `._canceller` from any `RemoteActorError.src_actor_uid` or
  failing over to the `.chan.uid` when a non-remote error (tho that
  shouldn't ever happen right?).
- more extensive doc-string for `.cancel()` detailing the new strictness
  rules about whether an eventual `.cancel_acked` might be set.

Also tossed in even more logging format tweaks by adding a
`type_only: bool` to `.repr_outcome()` as desired for simpler output in
the `state: <outcome-repr-here>` and `.repr_rpc()` sections of the
`.__str__()`.
2024-03-07 20:35:43 -05:00
..
devx Add `shield: bool` support to `.pause()` 2024-03-06 14:37:54 -05:00
experimental Move move context code into new `._context` mod 2023-05-15 10:00:45 -04:00
msg Make `NamespacePath` kinda support methods.. 2024-02-29 17:37:02 -05:00
trionics Try allowing multi-pops of `_Cache.locks` for now? 2024-01-23 11:13:07 -05:00
__init__.py Use `import <name> as <name>,` style over `__all__` in pkg mod 2024-01-02 10:25:17 -05:00
_child.py ._child: remove some unused imports.. 2024-01-02 10:24:39 -05:00
_clustering.py Passthrough runtime kwargs from `open_actor_cluster()` 2022-12-11 19:56:08 -05:00
_context.py (Event) more pedantic `.cancel_acked: bool` def 2024-03-07 20:35:43 -05:00
_discovery.py `.discovery.get_arbiter()`: add warning around this now deprecated usage 2023-12-11 19:37:45 -05:00
_entry.py `._entry`: use same msg info in start/terminate log 2024-03-05 12:30:34 -05:00
_exceptions.py Add "fancier" remote-error `.__repr__()`-ing 2024-02-29 18:56:31 -05:00
_forkserver_override.py Re-license code base for distribution under AGPL 2021-12-14 23:33:27 -05:00
_ipc.py Fix `Channel.__repr__()` safety, renames to `._transport` 2024-02-29 18:37:04 -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.. 2023-11-06 15:44:21 -05:00
_portal.py Tweak `._portal` log content to use `Context.repr_outcome()` 2024-03-05 12:26:33 -05:00
_root.py `._entry`: use same msg info in start/terminate log 2024-03-05 12:30:34 -05:00
_runtime.py Set `._cancel_msg` to RPC `{cmd: 'self._cancel_task', ..}` msg 2024-03-07 18:24:00 -05:00
_shm.py Updates from latest `piker.data._sharedmem` changes 2023-06-22 17:16:17 -04:00
_spawn.py Spawn naming and log format tweaks 2024-03-01 11:37:23 -05:00
_state.py Move `NoRuntime` import inside `current_actor()` to avoid cycle 2023-05-15 10:00:45 -04:00
_streaming.py Make stream draining status logs `.debug()` level 2024-03-01 19:27:10 -05:00
_supervise.py Add `._implicit_runtime_started` mark, better logs 2024-03-01 15:44:01 -05:00
log.py .log: more multi-line styling 2024-02-20 13:22:44 -05:00
to_asyncio.py Move `.to_asyncio` to modern optional value type annots 2023-07-21 15:08:46 -04:00