From fefb30d264420448ecef88bcdfe455a7ac417b76 Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Fri, 13 Sep 2024 12:20:32 +0200 Subject: [PATCH] Fix: dictionary changed size during iteration Iterating over the keys of a dictionary is a lazy operation that uses a generator under the hood. An error was reported on Sentry due to "RuntimeError: dictionary changed size during iteration". This fixes the issue by transforming the generator into a list, which is the standard way to approach this issue in Python. --- src/aleph/vm/orchestrator/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aleph/vm/orchestrator/tasks.py b/src/aleph/vm/orchestrator/tasks.py index 3f468785..99c814a8 100644 --- a/src/aleph/vm/orchestrator/tasks.py +++ b/src/aleph/vm/orchestrator/tasks.py @@ -150,7 +150,7 @@ async def monitor_payments(app: web.Application): await asyncio.sleep(settings.PAYMENT_MONITOR_INTERVAL) # Check if the executions continues existing or are forgotten before checking the payment - for vm_hash in pool.executions.keys(): + for vm_hash in list(pool.executions.keys()): message_status = await get_message_status(vm_hash) if message_status != MessageStatus.PROCESSED: logger.debug(f"Stopping {vm_hash} execution due to {message_status} message status")