From 4a9e8731f15a57eac412984ec9f40b72d00cf37a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 8 Jul 2025 12:44:46 -0400 Subject: [PATCH] More prep-to-reduce the `Actor` method-iface - drop the (never/un)used `.get_chans()`. - add #TODO for factoring many methods into a new `.rpc`-subsys/pkg primitive, like an `RPCMngr/Server` type eventually. - add todo to maybe mv `.get_parent()` elsewhere? - move masked `._hard_mofo_kill()` to bottom. --- tractor/_runtime.py | 59 ++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/tractor/_runtime.py b/tractor/_runtime.py index bbb85799..922f5daa 100644 --- a/tractor/_runtime.py +++ b/tractor/_runtime.py @@ -552,6 +552,14 @@ class Actor: ) raise + # ?TODO, factor this meth-iface into a new `.rpc` subsys primitive? + # - _get_rpc_func(), + # - _deliver_ctx_payload(), + # - get_context(), + # - start_remote_task(), + # - cancel_rpc_tasks(), + # - _cancel_task(), + # def _get_rpc_func(self, ns, funcname): ''' Try to lookup and return a target RPC func from the @@ -1119,14 +1127,6 @@ class Actor: self._cancel_complete.set() return True - # XXX: hard kill logic if needed? - # def _hard_mofo_kill(self): - # # If we're the root actor or zombied kill everything - # if self._parent_chan is None: # TODO: more robust check - # root = trio.lowlevel.current_root_task() - # for n in root.child_nurseries: - # n.cancel_scope.cancel() - async def _cancel_task( self, cid: str, @@ -1361,25 +1361,13 @@ class Actor: ''' return self.accept_addrs[0] - def get_parent(self) -> Portal: - ''' - Return a `Portal` to our parent. - - ''' - assert self._parent_chan, "No parent channel for this actor?" - return Portal(self._parent_chan) - - def get_chans( - self, - uid: tuple[str, str], - - ) -> list[Channel]: - ''' - Return all IPC channels to the actor with provided `uid`. - - ''' - return self._ipc_server._peers[uid] - + # TODO, this should delegate ONLY to the + # `._spawn_spec._runtime_vars: dict` / `._state` APIs? + # + # XXX, AH RIGHT that's why.. + # it's bc we pass this as a CLI flag to the child.py precisely + # bc we need the bootstrapping pre `async_main()`.. but maybe + # keep this as an impl deat and not part of the pub iface impl? def is_infected_aio(self) -> bool: ''' If `True`, this actor is running `trio` in guest mode on @@ -1390,6 +1378,23 @@ class Actor: ''' return self._infected_aio + # ?TODO, is this the right type for this method? + def get_parent(self) -> Portal: + ''' + Return a `Portal` to our parent. + + ''' + assert self._parent_chan, "No parent channel for this actor?" + return Portal(self._parent_chan) + + # XXX: hard kill logic if needed? + # def _hard_mofo_kill(self): + # # If we're the root actor or zombied kill everything + # if self._parent_chan is None: # TODO: more robust check + # root = trio.lowlevel.current_root_task() + # for n in root.child_nurseries: + # n.cancel_scope.cancel() + async def async_main( actor: Actor,