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.to_asyncio_eoc_signal
							parent
							
								
									6194ac891c
								
							
						
					
					
						commit
						e949839edf
					
				|  | @ -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, | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue