Skip to content

Commit ed65301

Browse files
committed
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) #429 (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code
1 parent 8817032 commit ed65301

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

tests/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def sig_prog(
212212
'''
213213
for i in range(tries):
214214
proc.send_signal(sig)
215-
if not proc.poll():
215+
if proc.poll() is None:
216216
print(
217217
f'WARNING, proc still alive after,\n'
218218
f'canc_timeout={canc_timeout!r}\n'
@@ -224,8 +224,7 @@ def sig_prog(
224224
else:
225225
# TODO: why sometimes does SIGINT not work on teardown?
226226
# seems to happen only when trace logging enabled?
227-
if not proc.poll():
228-
breakpoint()
227+
if proc.poll() is None:
229228
print(
230229
f'XXX WARNING KILLING PROG WITH SIGINT XXX\n'
231230
f'canc_timeout={canc_timeout!r}\n'

tractor/discovery/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
Discovery (protocols) API for automatic addressing
1919
and location management of (service) actors.
2020
21-
NOTE: to avoid circular imports, this ``__init__``
22-
does NOT eagerly import submodules. Use direct
23-
module paths like ``tractor.discovery._addr`` or
24-
``tractor.discovery._api`` instead.
21+
NOTE: this ``__init__`` only eagerly imports the
22+
``._multiaddr`` submodule (for public re-exports).
23+
Heavier submodules like ``._addr`` and ``._api``
24+
are NOT imported here to avoid circular imports;
25+
use direct module paths for those.
2526
2627
'''
2728
from ._multiaddr import (

tractor/discovery/_registry.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ async def register_actor(
196196
and addr_tup in other_addrs
197197
):
198198
other_addrs.remove(addr_tup)
199+
if not other_addrs:
200+
del self._registry[other_uid]
199201
break
200202

201203
# Append to this uid's addr list (avoid duplicates)

tractor/runtime/_runtime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ async def async_main(
15671567
# XXX, either passed in by caller or delivered
15681568
# in post spawn-spec handshake for subs.
15691569
if not accept_addrs:
1570-
RuntimeError(
1570+
raise RuntimeError(
15711571
f'No tpt bind addresses provided to actor!?\n'
15721572
f'parent_addr={parent_addr!r}\n'
15731573
f'accept_addrs={accept_addrs!r}\n'
@@ -1926,7 +1926,7 @@ async def async_main(
19261926
if failed_unreg:
19271927
teardown_report += (
19281928
f'-> Failed to unregister {actor.name} from '
1929-
f'registar @ {addr}\n'
1929+
f'registrar @ {addr}\n'
19301930
)
19311931

19321932
# Ensure all peers (actors connected to us as clients) are finished

0 commit comments

Comments
 (0)