From 81585d9e6e0427c018c17cf0184a47a02e030e71 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 9 Jan 2023 17:27:27 -0500 Subject: [PATCH] Set global registry addr after first entry point spawns `pikerd` --- piker/_daemon.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/piker/_daemon.py b/piker/_daemon.py index 6609338b..c40b63df 100644 --- a/piker/_daemon.py +++ b/piker/_daemon.py @@ -37,10 +37,15 @@ _root_dname = 'pikerd' _registry_host: str = '127.0.0.1' _registry_port: int = 6116 -_registry_addr = ( +_default_reg_addr: tuple[str, int] = ( _registry_host, _registry_port, ) + +# NOTE: this value is set as an actor-global once the first endpoint +# who is capable, spawns a `pikerd` service tree. +_registry_addr: tuple[str, int] | None = None + _tractor_kwargs: dict[str, Any] = { # use a different registry addr then tractor's default 'arbiter_addr': _registry_addr @@ -152,13 +157,17 @@ async def open_pikerd( ''' global _services + global _registry_addr + + if _registry_addr is None: + _registry_addr = registry_addr or _default_reg_addr # XXX: this may open a root actor as well async with ( tractor.open_root_actor( # passed through to ``open_root_actor`` - arbiter_addr=registry_addr or _registry_addr, + arbiter_addr=_registry_addr, name=_root_dname, loglevel=loglevel, debug_mode=debug_mode, @@ -197,7 +206,7 @@ async def open_piker_runtime( # XXX: you should pretty much never want debug mode # for data daemons when running in production. debug_mode: bool = False, - registry_addr: None | tuple[str, int] = _registry_addr, + registry_addr: None | tuple[str, int] = None, ) -> tractor.Actor: ''' @@ -206,13 +215,17 @@ async def open_piker_runtime( ''' global _services + global _registry_addr + + if _registry_addr is None: + _registry_addr = registry_addr or _default_reg_addr # XXX: this may open a root actor as well async with ( tractor.open_root_actor( # passed through to ``open_root_actor`` - arbiter_addr=registry_addr, + arbiter_addr=_registry_addr, name=name, loglevel=loglevel, debug_mode=debug_mode,