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