Guard `reg_portal` for `None` in `maybe_open_portal()`
Fix potential `AttributeError` when `query_actor()` yields a `None` portal (peer-found-locally path) and an `OSError` is raised during transport connect. Also, - fix `Arbiter.delete_addr()` return type to `tuple[str, str]|None` bc it can return `None`. - fix "registar" typo -> "registrar" in comment. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codemulticast_revertable_streams
parent
d929fb75b5
commit
850219f60c
|
|
@ -222,8 +222,9 @@ async def maybe_open_portal(
|
||||||
# to) indicate that the target actor can't be
|
# to) indicate that the target actor can't be
|
||||||
# contacted at that addr.
|
# contacted at that addr.
|
||||||
except OSError:
|
except OSError:
|
||||||
# NOTE: ensure we delete the stale entry from the
|
# NOTE: ensure we delete the stale entry
|
||||||
# registar actor.
|
# from the registrar actor when available.
|
||||||
|
if reg_portal is not None:
|
||||||
uid: tuple[str, str] = await reg_portal.run_from_ns(
|
uid: tuple[str, str] = await reg_portal.run_from_ns(
|
||||||
'self',
|
'self',
|
||||||
'delete_addr',
|
'delete_addr',
|
||||||
|
|
@ -234,6 +235,12 @@ async def maybe_open_portal(
|
||||||
f'addr: {addr!r}\n'
|
f'addr: {addr!r}\n'
|
||||||
f'uid: {uid!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
|
yield None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2038,7 +2038,7 @@ class Arbiter(Actor):
|
||||||
async def delete_addr(
|
async def delete_addr(
|
||||||
self,
|
self,
|
||||||
addr: tuple[str, int|str],
|
addr: tuple[str, int|str],
|
||||||
) -> tuple[str, str]:
|
) -> tuple[str, str]|None:
|
||||||
uid: tuple | None = self._registry.inverse.pop(
|
uid: tuple | None = self._registry.inverse.pop(
|
||||||
addr,
|
addr,
|
||||||
None,
|
None,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue