forked from goodboy/tractor
1
0
Fork 0

Avoid mutate on iterate race

transport_hardening
Tyler Goodlet 2021-06-10 13:59:08 -04:00
parent 9b70f5d312
commit b6dd58b1cf
1 changed files with 4 additions and 1 deletions

View File

@ -537,11 +537,14 @@ class Actor:
async for msg in chan: async for msg in chan:
if msg is None: # loop terminate sentinel if msg is None: # loop terminate sentinel
log.debug( log.debug(
f"Cancelling all tasks for {chan} from {chan.uid}") 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: if channel is chan:
await self._cancel_task(cid, channel) await self._cancel_task(cid, channel)
log.debug( log.debug(
f"Msg loop signalled to terminate for" f"Msg loop signalled to terminate for"
f" {chan} from {chan.uid}") f" {chan} from {chan.uid}")