Avoid mutate on iterate race

wip_fix_asyncio_gen_streaming
Tyler Goodlet 2021-06-10 13:59:08 -04:00
parent b29d2f7053
commit 52f135d85d
1 changed files with 4 additions and 1 deletions

View File

@ -528,11 +528,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}")