From 0b9ae7419286d537370bda1b58add9f0e6a2d4c5 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 18 Aug 2023 21:04:44 +1000 Subject: [PATCH] fix(stats): RuntimeError: dictionary changed size during iteration --- invokeai/app/services/invocation_stats.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/invokeai/app/services/invocation_stats.py b/invokeai/app/services/invocation_stats.py index 75c36d0e16..6c0b90626e 100644 --- a/invokeai/app/services/invocation_stats.py +++ b/invokeai/app/services/invocation_stats.py @@ -259,12 +259,12 @@ class InvocationStatsService(InvocationStatsServiceBase): def log_stats(self): completed = set() + errored = set() for graph_id, node_log in self._stats.items(): try: current_graph_state = self.graph_execution_manager.get(graph_id) - except ValidationError: - del self._stats[graph_id] - del self._cache_stats[graph_id] + except Exception: + errored.add(graph_id) continue if not current_graph_state.is_complete(): @@ -299,3 +299,7 @@ class InvocationStatsService(InvocationStatsServiceBase): for graph_id in completed: del self._stats[graph_id] del self._cache_stats[graph_id] + + for graph_id in errored: + del self._stats[graph_id] + del self._cache_stats[graph_id]