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
subint_spawner_backend
Gud Boi 2026-04-14 18:32:55 -04:00
parent 8817032c90
commit ed65301d32
4 changed files with 11 additions and 9 deletions

View File

@ -212,7 +212,7 @@ def sig_prog(
''' '''
for i in range(tries): for i in range(tries):
proc.send_signal(sig) proc.send_signal(sig)
if not proc.poll(): if proc.poll() is None:
print( print(
f'WARNING, proc still alive after,\n' f'WARNING, proc still alive after,\n'
f'canc_timeout={canc_timeout!r}\n' f'canc_timeout={canc_timeout!r}\n'
@ -224,8 +224,7 @@ def sig_prog(
else: else:
# TODO: why sometimes does SIGINT not work on teardown? # TODO: why sometimes does SIGINT not work on teardown?
# seems to happen only when trace logging enabled? # seems to happen only when trace logging enabled?
if not proc.poll(): if proc.poll() is None:
breakpoint()
print( print(
f'XXX WARNING KILLING PROG WITH SIGINT XXX\n' f'XXX WARNING KILLING PROG WITH SIGINT XXX\n'
f'canc_timeout={canc_timeout!r}\n' f'canc_timeout={canc_timeout!r}\n'

View File

@ -18,10 +18,11 @@
Discovery (protocols) API for automatic addressing Discovery (protocols) API for automatic addressing
and location management of (service) actors. and location management of (service) actors.
NOTE: to avoid circular imports, this ``__init__`` NOTE: this ``__init__`` only eagerly imports the
does NOT eagerly import submodules. Use direct ``._multiaddr`` submodule (for public re-exports).
module paths like ``tractor.discovery._addr`` or Heavier submodules like ``._addr`` and ``._api``
``tractor.discovery._api`` instead. are NOT imported here to avoid circular imports;
use direct module paths for those.
''' '''
from ._multiaddr import ( from ._multiaddr import (

View File

@ -196,6 +196,8 @@ class Registrar(Actor):
and addr_tup in other_addrs and addr_tup in other_addrs
): ):
other_addrs.remove(addr_tup) other_addrs.remove(addr_tup)
if not other_addrs:
del self._registry[other_uid]
break break
# Append to this uid's addr list (avoid duplicates) # Append to this uid's addr list (avoid duplicates)

View File

@ -1567,7 +1567,7 @@ async def async_main(
# XXX, either passed in by caller or delivered # XXX, either passed in by caller or delivered
# in post spawn-spec handshake for subs. # in post spawn-spec handshake for subs.
if not accept_addrs: if not accept_addrs:
RuntimeError( raise RuntimeError(
f'No tpt bind addresses provided to actor!?\n' f'No tpt bind addresses provided to actor!?\n'
f'parent_addr={parent_addr!r}\n' f'parent_addr={parent_addr!r}\n'
f'accept_addrs={accept_addrs!r}\n' f'accept_addrs={accept_addrs!r}\n'
@ -1926,7 +1926,7 @@ async def async_main(
if failed_unreg: if failed_unreg:
teardown_report += ( teardown_report += (
f'-> Failed to unregister {actor.name} from ' 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 # Ensure all peers (actors connected to us as clients) are finished