Skip to content

Commit

Permalink
Convert actor UIDs to hashable tuples
Browse files Browse the repository at this point in the history
`msgspec` sends python lists over the wire
(jcrist/msgspec#30) which is fine and dandy
but we use them as lookup keys so we need to be sure we tuple-cast
first.
  • Loading branch information
goodboy committed Sep 18, 2021
1 parent 43a31ed commit 344076e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tractor/_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def __init__(
# @dataclass once we get py3.7
self.loglevel = loglevel

self._arb_addr = arbiter_addr or (None, None)
self._arb_addr = arbiter_addr

# marked by the process spawning backend at startup
# will be None for the parent most process started manually
Expand Down Expand Up @@ -797,8 +797,8 @@ async def _from_parent(
# XXX: msgspec doesn't support serializing tuples
# so just cash manually here since it's what our
# internals expect.
address: Tuple[str, int] = value
self._arb_addr = value
address: Tuple[str, int] = tuple(value)
self._arb_addr = address

else:
setattr(self, attr, value)
Expand Down Expand Up @@ -1181,7 +1181,7 @@ async def _do_handshake(
parlance.
"""
await chan.send(self.uid)
uid: Tuple[str, str] = await chan.recv()
uid: Tuple[str, str] = tuple(await chan.recv())

if not isinstance(uid, tuple):
raise ValueError(f"{uid} is not a valid uid?!")
Expand Down Expand Up @@ -1254,7 +1254,7 @@ async def register_actor(
sockaddr: Tuple[str, str]

) -> None:
name, uuid = tuple(uid)
name, uuid = uid = tuple(uid)
self._registry[uid] = tuple(sockaddr)

# pop and signal all waiter events
Expand Down

0 comments on commit 344076e

Please sign in to comment.