From 40ad00ce0200e775b8941e67b80ac6f613ffed60 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 10 Jun 2021 13:59:08 -0400 Subject: [PATCH] Avoid mutate on iterate race --- tractor/_actor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tractor/_actor.py b/tractor/_actor.py index e83af8d..64ef01d 100644 --- a/tractor/_actor.py +++ b/tractor/_actor.py @@ -535,11 +535,14 @@ class Actor: 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( f"Msg loop signalled to terminate for" f" {chan} from {chan.uid}")