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