Skip to content

Commit 87c1113

Browse files
committed
Always set default reg addr in find_actor() if not defined
1 parent 43b659d commit 87c1113

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

tractor/_discovery.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from __future__ import annotations
2323
from typing import (
2424
AsyncGenerator,
25+
AsyncContextManager,
2526
TYPE_CHECKING,
2627
)
2728
from contextlib import asynccontextmanager as acm
@@ -190,11 +191,19 @@ async def maybe_open_portal_from_reg_addr(
190191
else:
191192
yield None
192193

194+
if not registry_addrs:
195+
from ._root import _default_lo_addrs
196+
registry_addrs = _default_lo_addrs
197+
198+
maybe_portals: list[
199+
AsyncContextManager[tuple[str, int]]
200+
] = list(
201+
maybe_open_portal_from_reg_addr(addr)
202+
for addr in registry_addrs
203+
)
204+
193205
async with gather_contexts(
194-
mngrs=list(
195-
maybe_open_portal_from_reg_addr(addr)
196-
for addr in registry_addrs
197-
)
206+
mngrs=maybe_portals,
198207
) as maybe_portals:
199208
print(f'Portalz: {maybe_portals}')
200209
if not maybe_portals:
@@ -206,6 +215,9 @@ async def maybe_open_portal_from_reg_addr(
206215
yield portals[0]
207216

208217
else:
218+
# TODO: currently this may return multiple portals
219+
# given there are multi-homed or multiple registrars..
220+
# SO, we probably need de-duplication logic?
209221
yield portals
210222

211223

0 commit comments

Comments
 (0)