From ed65301d32dabcec8a18e55825ec008b21b7eda2 Mon Sep 17 00:00:00 2001 From: goodboy Date: Tue, 14 Apr 2026 18:32:55 -0400 Subject: [PATCH] Fix misc bugs caught by Copilot review Deats, - use `proc.poll() is None` in `sig_prog()` to distinguish "still running" from exit code 0; drop stale `breakpoint()` from fallback kill path (would hang CI). - add missing `raise` on the `RuntimeError` in `async_main()` when no tpt bind addrs given. - clean up stale uid entries from the registrar `_registry` when addr eviction empties the addr list. - update `discovery.__init__` docstring to match the new eager `._multiaddr` import. - fix `registar` -> `registrar` typo in teardown report log msg. Review: PR #429 (Copilot) https://github.com/goodboy/tractor/pull/429 (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tests/conftest.py | 5 ++--- tractor/discovery/__init__.py | 9 +++++---- tractor/discovery/_registry.py | 2 ++ tractor/runtime/_runtime.py | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1fad2255..c7b20531 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -212,7 +212,7 @@ def sig_prog( ''' for i in range(tries): proc.send_signal(sig) - if not proc.poll(): + if proc.poll() is None: print( f'WARNING, proc still alive after,\n' f'canc_timeout={canc_timeout!r}\n' @@ -224,8 +224,7 @@ def sig_prog( else: # TODO: why sometimes does SIGINT not work on teardown? # seems to happen only when trace logging enabled? - if not proc.poll(): - breakpoint() + if proc.poll() is None: print( f'XXX WARNING KILLING PROG WITH SIGINT XXX\n' f'canc_timeout={canc_timeout!r}\n' diff --git a/tractor/discovery/__init__.py b/tractor/discovery/__init__.py index 93c19e62..1ac8415d 100644 --- a/tractor/discovery/__init__.py +++ b/tractor/discovery/__init__.py @@ -18,10 +18,11 @@ Discovery (protocols) API for automatic addressing and location management of (service) actors. -NOTE: to avoid circular imports, this ``__init__`` -does NOT eagerly import submodules. Use direct -module paths like ``tractor.discovery._addr`` or -``tractor.discovery._api`` instead. +NOTE: this ``__init__`` only eagerly imports the +``._multiaddr`` submodule (for public re-exports). +Heavier submodules like ``._addr`` and ``._api`` +are NOT imported here to avoid circular imports; +use direct module paths for those. ''' from ._multiaddr import ( diff --git a/tractor/discovery/_registry.py b/tractor/discovery/_registry.py index dd235753..7cedb391 100644 --- a/tractor/discovery/_registry.py +++ b/tractor/discovery/_registry.py @@ -196,6 +196,8 @@ class Registrar(Actor): and addr_tup in other_addrs ): other_addrs.remove(addr_tup) + if not other_addrs: + del self._registry[other_uid] break # Append to this uid's addr list (avoid duplicates) diff --git a/tractor/runtime/_runtime.py b/tractor/runtime/_runtime.py index 6ff669a7..bee9e20d 100644 --- a/tractor/runtime/_runtime.py +++ b/tractor/runtime/_runtime.py @@ -1567,7 +1567,7 @@ async def async_main( # XXX, either passed in by caller or delivered # in post spawn-spec handshake for subs. if not accept_addrs: - RuntimeError( + raise RuntimeError( f'No tpt bind addresses provided to actor!?\n' f'parent_addr={parent_addr!r}\n' f'accept_addrs={accept_addrs!r}\n' @@ -1926,7 +1926,7 @@ async def async_main( if failed_unreg: teardown_report += ( f'-> Failed to unregister {actor.name} from ' - f'registar @ {addr}\n' + f'registrar @ {addr}\n' ) # Ensure all peers (actors connected to us as clients) are finished