Skip to content

Commit

Permalink
Cast to tuples for all uids explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed Jun 2, 2021
1 parent 727a208 commit 770a9e5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tractor/_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def __init__(
# TODO: consider making this a dynamically defined
# @dataclass once we get py3.7
self.loglevel = loglevel
self._arb_addr = arbiter_addr
self._arb_addr = tuple(arbiter_addr) if arbiter_addr is not None else None

# marked by the process spawning backend at startup
# will be None for the parent most process started manually
Expand Down Expand Up @@ -527,10 +527,11 @@ async def _process_messages(
# ``scope = Nursery.start()``
task_status.started(loop_cs)
async for msg in chan:

if msg is None: # loop terminate sentinel
log.debug(
f"Cancelling all tasks for {chan} from {chan.uid}")
for (channel, cid) in self._rpc_tasks:
for (channel, cid) in self._rpc_tasks.copy():
if channel is chan:
await self._cancel_task(cid, channel)
log.debug(
Expand Down Expand Up @@ -1070,10 +1071,10 @@ 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?!")
# if not isinstance(uid, tuple):
# raise ValueError(f"{uid} is not a valid uid?!")

chan.uid = uid
log.info(f"Handshake with actor {uid}@{chan.raddr} complete")
Expand Down Expand Up @@ -1143,8 +1144,9 @@ async def wait_for_actor(
async def register_actor(
self, uid: Tuple[str, str], sockaddr: Tuple[str, int]
) -> None:
uid = tuple(uid)
name, uuid = uid
self._registry[uid] = sockaddr
self._registry[uid] = tuple(sockaddr)

# pop and signal all waiter events
events = self._waiters.pop(name, ())
Expand All @@ -1154,4 +1156,4 @@ async def register_actor(
event.set()

async def unregister_actor(self, uid: Tuple[str, str]) -> None:
self._registry.pop(uid)
self._registry.pop(tuple(uid))

0 comments on commit 770a9e5

Please sign in to comment.