Change remaining internals to use `Actor.reg_addrs`
parent
1d6f55543d
commit
9da3b63644
|
@ -133,14 +133,12 @@ async def query_actor(
|
|||
)
|
||||
regaddr: list[tuple[str, int]] = arbiter_sockaddr
|
||||
|
||||
regstr: Portal
|
||||
async with get_registry(
|
||||
*(regaddr or actor._reg_addrs[0])
|
||||
) as regstr:
|
||||
|
||||
reg_portal: Portal
|
||||
regaddr: tuple[str, int] = regaddr or actor.reg_addrs[0]
|
||||
async with get_registry(*regaddr) as reg_portal:
|
||||
# TODO: return portals to all available actors - for now
|
||||
# just the last one that registered
|
||||
sockaddr: tuple[str, int] = await regstr.run_from_ns(
|
||||
sockaddr: tuple[str, int] = await reg_portal.run_from_ns(
|
||||
'self',
|
||||
'find_actor',
|
||||
name=name,
|
||||
|
@ -155,6 +153,7 @@ async def find_actor(
|
|||
registry_addrs: list[tuple[str, int]] | None = None,
|
||||
|
||||
only_first: bool = True,
|
||||
raise_on_none: bool = False,
|
||||
|
||||
) -> AsyncGenerator[
|
||||
Portal | list[Portal] | None,
|
||||
|
@ -207,13 +206,20 @@ async def find_actor(
|
|||
|
||||
async with gather_contexts(
|
||||
mngrs=maybe_portals,
|
||||
) as maybe_portals:
|
||||
print(f'Portalz: {maybe_portals}')
|
||||
if not maybe_portals:
|
||||
) as portals:
|
||||
# log.runtime(
|
||||
# 'Gathered portals:\n'
|
||||
# f'{portals}'
|
||||
# )
|
||||
if not portals:
|
||||
if raise_on_none:
|
||||
raise RuntimeError(
|
||||
f'No {name} found registered @ {registry_addrs}'
|
||||
)
|
||||
yield None
|
||||
return
|
||||
|
||||
portals: list[Portal] = list(maybe_portals)
|
||||
portals: list[Portal] = list(portals)
|
||||
if only_first:
|
||||
yield portals[0]
|
||||
|
||||
|
@ -250,9 +256,9 @@ async def wait_for_actor(
|
|||
|
||||
# TODO: use `.trionics.gather_contexts()` like
|
||||
# above in `find_actor()` as well?
|
||||
async with get_registry(
|
||||
*(registry_addr or actor._reg_addrs[0]), # first if not passed
|
||||
) as reg_portal:
|
||||
reg_portal: Portal
|
||||
regaddr: tuple[str, int] = registry_addr or actor.reg_addrs[0]
|
||||
async with get_registry(*regaddr) as reg_portal:
|
||||
sockaddrs = await reg_portal.run_from_ns(
|
||||
'self',
|
||||
'wait_for_actor',
|
||||
|
|
|
@ -85,7 +85,7 @@ async def open_root_actor(
|
|||
enable_modules: list | None = None,
|
||||
rpc_module_paths: list | None = None,
|
||||
|
||||
) -> typing.Any:
|
||||
) -> Actor:
|
||||
'''
|
||||
Runtime init entry point for ``tractor``.
|
||||
|
||||
|
@ -195,7 +195,10 @@ async def open_root_actor(
|
|||
|
||||
async with trio.open_nursery() as tn:
|
||||
for addr in registry_addrs:
|
||||
tn.start_soon(ping_tpt_socket, addr)
|
||||
tn.start_soon(
|
||||
ping_tpt_socket,
|
||||
tuple(addr), # TODO: just drop this requirement?
|
||||
)
|
||||
|
||||
trans_bind_addrs: list[tuple[str, int]] = []
|
||||
|
||||
|
|
|
@ -423,7 +423,7 @@ async def trio_proc(
|
|||
await chan.send({
|
||||
'_parent_main_data': subactor._parent_main_data,
|
||||
'enable_modules': subactor.enable_modules,
|
||||
'_reg_addrs': subactor._reg_addrs,
|
||||
'reg_addrs': subactor.reg_addrs,
|
||||
'bind_addrs': bind_addrs,
|
||||
'_runtime_vars': _runtime_vars,
|
||||
})
|
||||
|
|
|
@ -149,7 +149,7 @@ class ActorNursery:
|
|||
loglevel=loglevel,
|
||||
|
||||
# verbatim relay this actor's registrar addresses
|
||||
registry_addrs=current_actor()._reg_addrs,
|
||||
registry_addrs=current_actor().reg_addrs,
|
||||
)
|
||||
parent_addr = self._actor.accept_addr
|
||||
assert parent_addr
|
||||
|
|
Loading…
Reference in New Issue