From 82100775a217cf4fd2b106d97273e59010861523 Mon Sep 17 00:00:00 2001 From: Tim Pansino Date: Wed, 16 Nov 2022 10:21:44 -0800 Subject: [PATCH] Fix trace cache iteration crash --- newrelic/core/trace_cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/newrelic/core/trace_cache.py b/newrelic/core/trace_cache.py index 1634d0d0b..52492afd1 100644 --- a/newrelic/core/trace_cache.py +++ b/newrelic/core/trace_cache.py @@ -197,7 +197,7 @@ def active_threads(self): debug = global_settings().debug if debug.enable_coroutine_profiling: - for thread_id, trace in list(self._cache.items()): + for thread_id, trace in self._cache.copy().items(): transaction = trace.transaction if transaction and transaction._greenlet is not None: gr = transaction._greenlet() @@ -359,7 +359,7 @@ def record_event_loop_wait(self, start_time, end_time): task = getattr(transaction.root_span, "_task", None) loop = get_event_loop(task) - for trace in list(self._cache.values()): + for trace in self._cache.copy().values(): if trace in seen: continue