Use `aid.uid` over manual `(name, uuid)` tuples
The `.uid`->`.aid` migration (prior commits) re-assembled the legacy uid pair by hand as `(x.aid.name, x.aid.uuid)`. `Aid.uid` (`msg/types.py`) is the non-deprecated canonical property returning exactly that pair, so swap to `x.aid.uid` everywhere — byte-identical, just DRY + consistent. Covers the 5 review-flagged source sites (`msg._ops`, `devx.debug._sync`, `experimental._pubsub`, `_exceptions`) plus the ~22 unflagged identical sites (`_streaming` f-string logs + 6 test modules); also tightens the `_exceptions` `our_uid` annotation to `tuple[str, str]`. Review: PR #469 (copilot-pull-request-reviewer) https://github.com/goodboy/tractor/pull/469#pullrequestreview-4575979601 (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codewkt/rm_test_warnings
parent
3e04968e79
commit
bffeba952a
|
|
@ -123,10 +123,10 @@ def test_register_duplicate_name(
|
||||||
'`wait_for_actor` returned'
|
'`wait_for_actor` returned'
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
(portal.channel.aid.name, portal.channel.aid.uuid)
|
portal.channel.aid.uid
|
||||||
in (
|
in (
|
||||||
(p2.channel.aid.name, p2.channel.aid.uuid),
|
p2.channel.aid.uid,
|
||||||
(p1.channel.aid.name, p1.channel.aid.uuid),
|
p1.channel.aid.uid,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -249,11 +249,11 @@ def test_dup_name_cancel_cascade_escalates_to_hard_kill(
|
||||||
# have last-wins semantics under same-name).
|
# have last-wins semantics under same-name).
|
||||||
async with tractor.wait_for_actor('doggy') as portal:
|
async with tractor.wait_for_actor('doggy') as portal:
|
||||||
expected_uids = {
|
expected_uids = {
|
||||||
(p.channel.aid.name, p.channel.aid.uuid)
|
p.channel.aid.uid
|
||||||
for p in portals
|
for p in portals
|
||||||
}
|
}
|
||||||
assert (
|
assert (
|
||||||
(portal.channel.aid.name, portal.channel.aid.uuid)
|
portal.channel.aid.uid
|
||||||
in expected_uids
|
in expected_uids
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ def enc_nsp(obj: Any) -> Any:
|
||||||
)
|
)
|
||||||
uid: tuple[str, str]|None = (
|
uid: tuple[str, str]|None = (
|
||||||
None if not actor
|
None if not actor
|
||||||
else (actor.aid.name, actor.aid.uuid)
|
else actor.aid.uid
|
||||||
)
|
)
|
||||||
print(f'{uid} ENC HOOK')
|
print(f'{uid} ENC HOOK')
|
||||||
|
|
||||||
|
|
@ -100,7 +100,7 @@ def dec_nsp(
|
||||||
)
|
)
|
||||||
uid: tuple[str, str]|None = (
|
uid: tuple[str, str]|None = (
|
||||||
None if not actor
|
None if not actor
|
||||||
else (actor.aid.name, actor.aid.uuid)
|
else actor.aid.uid
|
||||||
)
|
)
|
||||||
print(
|
print(
|
||||||
f'{uid}\n'
|
f'{uid}\n'
|
||||||
|
|
@ -426,7 +426,7 @@ async def send_back_values(
|
||||||
|
|
||||||
'''
|
'''
|
||||||
_aid = tractor.current_actor().aid
|
_aid = tractor.current_actor().aid
|
||||||
uid: tuple = (_aid.name, _aid.uuid)
|
uid: tuple = _aid.uid
|
||||||
|
|
||||||
# init state in sub-actor should be default
|
# init state in sub-actor should be default
|
||||||
chk_codec_applied(
|
chk_codec_applied(
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ async def subscribe(
|
||||||
new_subs = set(new_subs)
|
new_subs = set(new_subs)
|
||||||
remove = new_subs - _registry.keys()
|
remove = new_subs - _registry.keys()
|
||||||
|
|
||||||
print(f'setting sub to {new_subs} for {(ctx.chan.aid.name, ctx.chan.aid.uuid)}')
|
print(f'setting sub to {new_subs} for {ctx.chan.aid.uid}')
|
||||||
|
|
||||||
# remove old subs
|
# remove old subs
|
||||||
for sub in remove:
|
for sub in remove:
|
||||||
|
|
@ -85,7 +85,7 @@ async def consumer(
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
_aid = tractor.current_actor().aid
|
_aid = tractor.current_actor().aid
|
||||||
uid = (_aid.name, _aid.uuid)
|
uid = _aid.uid
|
||||||
|
|
||||||
async with tractor.wait_for_actor('publisher') as portal:
|
async with tractor.wait_for_actor('publisher') as portal:
|
||||||
async with portal.open_context(subscribe) as (ctx, first):
|
async with portal.open_context(subscribe) as (ctx, first):
|
||||||
|
|
|
||||||
|
|
@ -311,7 +311,7 @@ def test_parent_cancels(
|
||||||
ctx: Context,
|
ctx: Context,
|
||||||
) -> None:
|
) -> None:
|
||||||
actor: Actor = current_actor()
|
actor: Actor = current_actor()
|
||||||
uid: tuple = (actor.aid.name, actor.aid.uuid)
|
uid: tuple = actor.aid.uid
|
||||||
_ctxc: ContextCancelled|None = None
|
_ctxc: ContextCancelled|None = None
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
@ -712,9 +712,9 @@ async def test_parent_exits_ctx_after_child_enters_stream(
|
||||||
assert (
|
assert (
|
||||||
ctxc.canceller
|
ctxc.canceller
|
||||||
==
|
==
|
||||||
(current_actor().aid.name, current_actor().aid.uuid)
|
current_actor().aid.uid
|
||||||
==
|
==
|
||||||
(root.aid.name, root.aid.uuid)
|
root.aid.uid
|
||||||
)
|
)
|
||||||
|
|
||||||
# channel should still be up
|
# channel should still be up
|
||||||
|
|
@ -1219,7 +1219,7 @@ def test_maybe_allow_overruns_stream(
|
||||||
|
|
||||||
if cancel_ctx:
|
if cancel_ctx:
|
||||||
assert isinstance(res, ContextCancelled)
|
assert isinstance(res, ContextCancelled)
|
||||||
assert tuple(res.canceller) == (current_actor().aid.name, current_actor().aid.uuid)
|
assert tuple(res.canceller) == current_actor().aid.uid
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(f'RX ROOT SIDE RESULT {res}')
|
print(f'RX ROOT SIDE RESULT {res}')
|
||||||
|
|
|
||||||
|
|
@ -956,7 +956,7 @@ async def manage_file(
|
||||||
'''
|
'''
|
||||||
|
|
||||||
tmp_path: Path = Path(tmp_path_str)
|
tmp_path: Path = Path(tmp_path_str)
|
||||||
tmp_file: Path = tmp_path / f'{" ".join((ctx._actor.aid.name, ctx._actor.aid.uuid))}.file'
|
tmp_file: Path = tmp_path / f'{" ".join(ctx._actor.aid.uid)}.file'
|
||||||
|
|
||||||
# create a the tmp file and tell the parent where it's at
|
# create a the tmp file and tell the parent where it's at
|
||||||
assert not tmp_file.is_file()
|
assert not tmp_file.is_file()
|
||||||
|
|
@ -1180,7 +1180,7 @@ def test_sigint_closes_lifetime_stack(
|
||||||
):
|
):
|
||||||
await ctx.wait_for_result()
|
await ctx.wait_for_result()
|
||||||
except tractor.ContextCancelled as ctxc:
|
except tractor.ContextCancelled as ctxc:
|
||||||
assert ctxc.canceller == (ctx.chan.aid.name, ctx.chan.aid.uuid)
|
assert ctxc.canceller == ctx.chan.aid.uid
|
||||||
raise
|
raise
|
||||||
|
|
||||||
except trio.TooSlowError:
|
except trio.TooSlowError:
|
||||||
|
|
@ -1300,7 +1300,7 @@ async def caching_ep(
|
||||||
},
|
},
|
||||||
|
|
||||||
# lock around current actor task access
|
# lock around current actor task access
|
||||||
key=(tractor.current_actor().aid.name, tractor.current_actor().aid.uuid),
|
key=tractor.current_actor().aid.uid,
|
||||||
|
|
||||||
) as (cache_hit, (clients, chan)),
|
) as (cache_hit, (clients, chan)),
|
||||||
):
|
):
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ async def spawn(
|
||||||
|
|
||||||
assert len(an._children) == 1
|
assert len(an._children) == 1
|
||||||
assert (
|
assert (
|
||||||
(portal.channel.aid.name, portal.channel.aid.uuid)
|
portal.channel.aid.uid
|
||||||
in
|
in
|
||||||
tractor.current_actor().ipc_server._peers
|
tractor.current_actor().ipc_server._peers
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1223,7 +1223,7 @@ def pack_error(
|
||||||
str,
|
str,
|
||||||
str | tuple[str, str]
|
str | tuple[str, str]
|
||||||
] = {}
|
] = {}
|
||||||
our_uid: tuple = (current_actor().aid.name, current_actor().aid.uuid)
|
our_uid: tuple[str, str] = current_actor().aid.uid
|
||||||
|
|
||||||
if (
|
if (
|
||||||
isinstance(exc, RemoteActorError)
|
isinstance(exc, RemoteActorError)
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,7 @@ class MsgStream(trio.abc.Channel):
|
||||||
# it can't traverse the transport.
|
# it can't traverse the transport.
|
||||||
log.warning(
|
log.warning(
|
||||||
f'Stream was already destroyed?\n'
|
f'Stream was already destroyed?\n'
|
||||||
f'actor: {(ctx.chan.aid.name, ctx.chan.aid.uuid)}\n'
|
f'actor: {ctx.chan.aid.uid}\n'
|
||||||
f'ctx id: {ctx.cid}'
|
f'ctx id: {ctx.cid}'
|
||||||
)
|
)
|
||||||
drained.append(re)
|
drained.append(re)
|
||||||
|
|
@ -823,7 +823,7 @@ async def open_stream_from_ctx(
|
||||||
except KeyError:
|
except KeyError:
|
||||||
log.warning(
|
log.warning(
|
||||||
f'Stream was already destroyed?\n'
|
f'Stream was already destroyed?\n'
|
||||||
f'actor: {(ctx.chan.aid.name, ctx.chan.aid.uuid)}\n'
|
f'actor: {ctx.chan.aid.uid}\n'
|
||||||
f'ctx id: {ctx.cid}'
|
f'ctx id: {ctx.cid}'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,11 +92,11 @@ async def maybe_wait_for_debugger(
|
||||||
# tearing down.
|
# tearing down.
|
||||||
ctx_in_debug: Context|None = Lock.ctx_in_debug
|
ctx_in_debug: Context|None = Lock.ctx_in_debug
|
||||||
in_debug: tuple[str, str]|None = (
|
in_debug: tuple[str, str]|None = (
|
||||||
(ctx_in_debug.chan.aid.name, ctx_in_debug.chan.aid.uuid)
|
ctx_in_debug.chan.aid.uid
|
||||||
if ctx_in_debug
|
if ctx_in_debug
|
||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
if in_debug == (current_actor().aid.name, current_actor().aid.uuid):
|
if in_debug == current_actor().aid.uid:
|
||||||
log.debug(
|
log.debug(
|
||||||
msg
|
msg
|
||||||
+
|
+
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ def modify_subs(
|
||||||
|
|
||||||
Effectively a symbol subscription api.
|
Effectively a symbol subscription api.
|
||||||
"""
|
"""
|
||||||
log.info(f"{(ctx.chan.aid.name, ctx.chan.aid.uuid)} changed subscription to {topics}")
|
log.info(f"{ctx.chan.aid.uid} changed subscription to {topics}")
|
||||||
|
|
||||||
# update map from each symbol to requesting client's chan
|
# update map from each symbol to requesting client's chan
|
||||||
for topic in topics:
|
for topic in topics:
|
||||||
|
|
|
||||||
|
|
@ -345,9 +345,9 @@ class PldRx(Struct):
|
||||||
exc=mte,
|
exc=mte,
|
||||||
cid=msg.cid,
|
cid=msg.cid,
|
||||||
src_uid=(
|
src_uid=(
|
||||||
(ipc.chan.aid.name, ipc.chan.aid.uuid)
|
ipc.chan.aid.uid
|
||||||
if not is_started_send_side
|
if not is_started_send_side
|
||||||
else (ipc._actor.aid.name, ipc._actor.aid.uuid)
|
else ipc._actor.aid.uid
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
mte._ipc_msg = err_msg
|
mte._ipc_msg = err_msg
|
||||||
|
|
@ -711,7 +711,7 @@ async def drain_to_final_msg(
|
||||||
'Cancelling `MsgStream` drain since '
|
'Cancelling `MsgStream` drain since '
|
||||||
f'{reason}\n'
|
f'{reason}\n'
|
||||||
f'\n'
|
f'\n'
|
||||||
f'<= {(ctx.chan.aid.name, ctx.chan.aid.uuid)}\n'
|
f'<= {ctx.chan.aid.uid}\n'
|
||||||
f' |_{ctx._nsf}()\n'
|
f' |_{ctx._nsf}()\n'
|
||||||
f'\n'
|
f'\n'
|
||||||
f'=> {ctx._task}\n'
|
f'=> {ctx._task}\n'
|
||||||
|
|
@ -726,7 +726,7 @@ async def drain_to_final_msg(
|
||||||
else:
|
else:
|
||||||
report: str = (
|
report: str = (
|
||||||
'Ignoring "yield" msg during `ctx.result()` drain..\n'
|
'Ignoring "yield" msg during `ctx.result()` drain..\n'
|
||||||
f'<= {(ctx.chan.aid.name, ctx.chan.aid.uuid)}\n'
|
f'<= {ctx.chan.aid.uid}\n'
|
||||||
f' |_{ctx._nsf}()\n\n'
|
f' |_{ctx._nsf}()\n\n'
|
||||||
f'=> {ctx._task}\n'
|
f'=> {ctx._task}\n'
|
||||||
f' |_{ctx._stream}\n\n'
|
f' |_{ctx._stream}\n\n'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue