From 9fd3c42eb1a66a41c82c2b3e18e4ad4c5340085d Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 22 Dec 2020 10:26:07 -0500 Subject: [PATCH] Port inter-process method calls to `Portal.run_from_ns()` --- tractor/_actor.py | 9 ++++++--- tractor/_debug.py | 9 ++++----- tractor/_discovery.py | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tractor/_actor.py b/tractor/_actor.py index dba47ab..3dbdc5e 100644 --- a/tractor/_actor.py +++ b/tractor/_actor.py @@ -712,7 +712,7 @@ class Actor: assert isinstance(self._arb_addr, tuple) async with get_arbiter(*self._arb_addr) as arb_portal: - await arb_portal.run( + await arb_portal.run_from_ns( 'self', 'register_actor', uid=self.uid, @@ -788,8 +788,11 @@ class Actor: cs.shield = True try: async with get_arbiter(*self._arb_addr) as arb_portal: - await arb_portal.run( - 'self', 'unregister_actor', uid=self.uid) + await arb_portal.run_from_ns( + 'self', + 'unregister_actor', + uid=self.uid + ) except OSError: failed = True if cs.cancelled_caught: diff --git a/tractor/_debug.py b/tractor/_debug.py index 5bd1a2b..f9af7a6 100644 --- a/tractor/_debug.py +++ b/tractor/_debug.py @@ -180,15 +180,14 @@ def _breakpoint(debug_func) -> Awaitable[None]: try: async with get_root() as portal: with trio.fail_after(.5): - agen = await portal.run( - 'tractor._debug', - '_hijack_stdin_relay_to_child', + stream = await portal.run( + tractor._debug._hijack_stdin_relay_to_child, subactor_uid=actor.uid, ) - async with aclosing(agen): + async with aclosing(stream): # block until first yield above - async for val in agen: + async for val in stream: assert val == 'Locked' task_status.started() diff --git a/tractor/_discovery.py b/tractor/_discovery.py index 360b16d..9e520b3 100644 --- a/tractor/_discovery.py +++ b/tractor/_discovery.py @@ -60,7 +60,7 @@ async def find_actor( """ actor = current_actor() async with get_arbiter(*arbiter_sockaddr or actor._arb_addr) as arb_portal: - sockaddr = await arb_portal.run('self', 'find_actor', name=name) + sockaddr = await arb_portal.run_from_ns('self', 'find_actor', name=name) # TODO: return portals to all available actors - for now just # the last one that registered if name == 'arbiter' and actor.is_arbiter: @@ -84,7 +84,7 @@ async def wait_for_actor( """ actor = current_actor() async with get_arbiter(*arbiter_sockaddr or actor._arb_addr) as arb_portal: - sockaddrs = await arb_portal.run('self', 'wait_for_actor', name=name) + sockaddrs = await arb_portal.run_from_ns('self', 'wait_for_actor', name=name) sockaddr = sockaddrs[-1] async with _connect_chan(*sockaddr) as chan: async with open_portal(chan) as portal: