forked from goodboy/tractor
1
0
Fork 0

Port inter-process method calls to `Portal.run_from_ns()`

func_refs_always
Tyler Goodlet 2020-12-22 10:26:07 -05:00
parent 7134f35d6e
commit 9fd3c42eb1
3 changed files with 12 additions and 10 deletions

View File

@ -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:

View File

@ -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()

View File

@ -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: