Fix warns and de-reg race in `test_discovery`

Removes the `pytest` deprecation warns and attempts to avoid
some de-registration raciness, though i'm starting to think the
real issue is due to not having the fixes from #366 (which handle
the new dereg on `OSError` case from UDS)?

- use `.channel.aid.uid` over deprecated `.channel.uid`
  throughout `test_discovery.py`.
- add polling loop (up to 5s) for subactor de-reg check
  in `spawn_and_check_registry()` to handle slower
  transports like UDS where teardown takes longer.

(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
ns_aware
Gud Boi 2026-03-13 16:22:04 -04:00
parent dfc153c228
commit 8991ec2bf5
1 changed files with 20 additions and 6 deletions

View File

@ -7,6 +7,7 @@ import signal
import platform
from functools import partial
import itertools
import time
from typing import Callable
import psutil
@ -31,7 +32,7 @@ async def test_reg_then_unreg(
) as n:
portal = await n.start_actor('actor', enable_modules=[__name__])
uid = portal.channel.uid
uid = portal.channel.aid.uid
async with tractor.get_registry(reg_addr) as aportal:
# this local actor should be the arbiter
@ -205,7 +206,7 @@ async def spawn_and_check_registry(
# ensure current actor is registered
registry: dict = await get_reg()
assert actor.uid in registry
assert actor.aid.uid in registry
try:
async with tractor.open_nursery() as an:
@ -253,8 +254,21 @@ async def spawn_and_check_registry(
# all subactors should have de-registered
registry = await get_reg()
assert len(registry) == extra
assert actor.uid in registry
start: float = time.time()
while (
not (len(registry) == extra)
and
(time.time() - start) < 5
):
print(
f'Waiting for remaining subs to dereg..\n'
f'{registry!r}\n'
)
await trio.sleep(0.3)
else:
assert len(registry) == extra
assert actor.aid.uid in registry
@pytest.mark.parametrize('use_signal', [False, True])
@ -384,8 +398,8 @@ async def close_chans_before_nursery(
# all subactors should have de-registered
registry = await get_reg()
assert portal1.channel.uid not in registry
assert portal2.channel.uid not in registry
assert portal1.channel.aid.uid not in registry
assert portal2.channel.aid.uid not in registry
assert len(registry) == entries_at_end