Skip to content

Commit

Permalink
Add open_root_actor(ensure_registry: bool)
Browse files Browse the repository at this point in the history
Allows forcing the opened actor to either obtain the passed registry
addrs or raise a runtime error.
  • Loading branch information
goodboy committed Nov 7, 2023
1 parent 48accbd commit 87cd725
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tractor/_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ async def open_root_actor(
enable_modules: list | None = None,
rpc_module_paths: list | None = None,

# NOTE: allow caller to ensure that only one registry exists
# and that this call creates it.
ensure_registry: bool = False,

) -> Actor:
'''
Runtime init entry point for ``tractor``.
Expand Down Expand Up @@ -206,6 +210,12 @@ async def ping_tpt_socket(
# REGISTRAR
if ponged_addrs:

if ensure_registry:
raise RuntimeError(
f'Failed to open `{name}`@{ponged_addrs}: '
'registry socket(s) already bound'
)

# we were able to connect to an arbiter
logger.info(
f'Registry(s) seem(s) to exist @ {ponged_addrs}'
Expand Down

0 comments on commit 87cd725

Please sign in to comment.