diff --git a/tractor/_discovery.py b/tractor/_discovery.py index fd1d0cf8..49829b17 100644 --- a/tractor/_discovery.py +++ b/tractor/_discovery.py @@ -222,18 +222,25 @@ async def maybe_open_portal( # to) indicate that the target actor can't be # contacted at that addr. except OSError: - # NOTE: ensure we delete the stale entry from the - # registar actor. - uid: tuple[str, str] = await reg_portal.run_from_ns( - 'self', - 'delete_addr', - addr=addr, - ) - log.warning( - f'Deleted stale registry entry !\n' - f'addr: {addr!r}\n' - f'uid: {uid!r}\n' - ) + # NOTE: ensure we delete the stale entry + # from the registrar actor when available. + if reg_portal is not None: + uid: tuple[str, str] = await reg_portal.run_from_ns( + 'self', + 'delete_addr', + addr=addr, + ) + log.warning( + f'Deleted stale registry entry !\n' + f'addr: {addr!r}\n' + f'uid: {uid!r}\n' + ) + else: + log.warning( + f'Connection to {addr!r} failed' + f' and no registry portal available' + f' to delete stale entry.' + ) yield None diff --git a/tractor/_runtime.py b/tractor/_runtime.py index 633ec487..c4c0577a 100644 --- a/tractor/_runtime.py +++ b/tractor/_runtime.py @@ -2038,7 +2038,7 @@ class Arbiter(Actor): async def delete_addr( self, addr: tuple[str, int|str], - ) -> tuple[str, str]: + ) -> tuple[str, str]|None: uid: tuple | None = self._registry.inverse.pop( addr, None,