Skip to content

The agent that grows with you

test(code-kernel): snapshot the remote registry in the eviction spin-wait

teknium116bddc88dd32
diff --git a/tests/tools/test_code_kernel_remote.py b/tests/tools/test_code_kernel_remote.py
index f7eabefa0df..162aac30433 100644
--- a/tests/tools/test_code_kernel_remote.py
+++ b/tests/tools/test_code_kernel_remote.py
@@ -11,6 +11,7 @@ state_lost/state_reset reporting, fail-open, and owner isolation.
import json
import os
import sys
+import time
import unittest
from unittest.mock import patch
@@ -278,8 +279,10 @@ class TestIdleReapAndCapEviction(RemoteKernelBase):
with patch("tools.code_kernel._lifecycle_limits", return_value=(1, 1800)):
worker = threading.Thread(target=_run, args=(busy_env,), kwargs={"task": "busy"})
worker.start()
- while not any(k.attached for k in _REMOTE_KERNELS.values()):
- pass
+ # Snapshot: the worker thread inserts into the registry concurrently and a live
+ # dict iteration raises "dictionary changed size during iteration".
+ while not any(k.attached for k in list(_REMOTE_KERNELS.values())):
+ time.sleep(0.005)
env = ScriptedEnv(_spawn_ok_handlers([_cell()]))
_run(env, task="settled")
owners = {key[0] for key in _REMOTE_KERNELS}