Skip to content

Commit

Permalink
Fix: dictionary changed size during iteration
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hoh committed Sep 16, 2024
1 parent eb2863d commit fefb30d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/aleph/vm/orchestrator/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit fefb30d

Please sign in to comment.