Use `.aid.uid` to avoid deprecation warns in tests

- `test_inter_peer_cancellation`: swap all `.uid` refs
  on `Actor`, `Channel`, and `Portal` to `.aid.uid`
- `test_legacy_one_way_streaming`: same + fix `print()`
  to multiline style

(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 21:09:35 -04:00
parent 8868ff19f3
commit 5b8f6cf4c7
2 changed files with 17 additions and 14 deletions

View File

@ -581,7 +581,7 @@ def test_peer_canceller(
assert (
re.canceller
==
root.uid
root.aid.uid
)
else: # the other 2 ctxs
@ -590,7 +590,7 @@ def test_peer_canceller(
and (
re.canceller
==
canceller.channel.uid
canceller.channel.aid.uid
)
)
@ -745,7 +745,7 @@ def test_peer_canceller(
# -> each context should have received
# a silently absorbed context cancellation
# in its remote nursery scope.
# assert ctx.chan.uid == ctx.canceller
# assert ctx.chan.aid.uid == ctx.canceller
# NOTE: when an inter-peer cancellation
# occurred, we DO NOT expect this
@ -802,7 +802,7 @@ async def basic_echo_server(
'''
actor: Actor = tractor.current_actor()
uid: tuple = actor.uid
uid: tuple = actor.aid.uid
await ctx.started(uid)
async with ctx.open_stream() as ipc:
async for msg in ipc:
@ -857,7 +857,7 @@ async def serve_subactors(
f'|_{peer}\n'
)
await ipc.send((
peer.chan.uid,
peer.chan.aid.uid,
peer.chan.raddr.unwrap(),
))
@ -992,7 +992,7 @@ async def tell_little_bro(
sub_ctx.open_stream() as echo_ipc,
):
actor: Actor = current_actor()
uid: tuple = actor.uid
uid: tuple = actor.aid.uid
for i in range(rng_seed):
msg: tuple = (
uid,
@ -1097,7 +1097,7 @@ def test_peer_spawns_and_cancels_service_subactor(
) as (client_ctx, client_says),
):
root: Actor = current_actor()
spawner_uid: tuple = spawn_ctx.chan.uid
spawner_uid: tuple = spawn_ctx.chan.aid.uid
print(
f'Server says: {first}\n'
f'Client says: {client_says}\n'
@ -1116,7 +1116,7 @@ def test_peer_spawns_and_cancels_service_subactor(
print(
'Sub-spawn came online\n'
f'portal: {sub}\n'
f'.uid: {sub.actor.uid}\n'
f'.uid: {sub.actor.aid.uid}\n'
f'chan.raddr: {sub.chan.raddr}\n'
)
@ -1150,7 +1150,7 @@ def test_peer_spawns_and_cancels_service_subactor(
assert isinstance(res, ContextCancelled)
assert client_ctx.cancel_acked
assert res.canceller == root.uid
assert res.canceller == root.aid.uid
assert not raise_sub_spawn_error_after
# cancelling the spawner sub should
@ -1184,8 +1184,8 @@ def test_peer_spawns_and_cancels_service_subactor(
# little_bro: a `RuntimeError`.
#
check_inner_rte(rae)
assert rae.relay_uid == client.chan.uid
assert rae.src_uid == sub.chan.uid
assert rae.relay_uid == client.chan.aid.uid
assert rae.src_uid == sub.chan.aid.uid
assert not client_ctx.cancel_acked
assert (
@ -1214,12 +1214,12 @@ def test_peer_spawns_and_cancels_service_subactor(
except ContextCancelled as ctxc:
_ctxc = ctxc
print(
f'{root.uid} caught ctxc from ctx with {client_ctx.chan.uid}\n'
f'{root.aid.uid} caught ctxc from ctx with {client_ctx.chan.aid.uid}\n'
f'{repr(ctxc)}\n'
)
if not raise_sub_spawn_error_after:
assert ctxc.canceller == root.uid
assert ctxc.canceller == root.aid.uid
else:
assert ctxc.canceller == spawner_uid

View File

@ -190,7 +190,10 @@ async def aggregate(seed: int):
# leverage trio's built-in backpressure
await send_chan.send(value)
print(f"FINISHED ITERATING {portal.channel.uid}")
print(
f'FINISHED ITERATING!\n'
f'peer: {portal.channel.aid.uid}'
)
# spawn 2 trio tasks to collect streams and push to a local queue
async with trio.open_nursery() as tn: