Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Python dict race condition (#351)

Jakub Novák168e59faf6f7
diff --git a/.changeset/shiny-houses-fry.md b/.changeset/shiny-houses-fry.md
new file mode 100644
index 000000000..084a0cc71
--- /dev/null
+++ b/.changeset/shiny-houses-fry.md
@@ -0,0 +1,5 @@
+---
+"@e2b/python-sdk": patch
+---
+
+Fix race condition in python SDK
diff --git a/packages/python-sdk/e2b/sandbox/sandbox_rpc.py b/packages/python-sdk/e2b/sandbox/sandbox_rpc.py
index ee13d8131..b5c3abebb 100644
--- a/packages/python-sdk/e2b/sandbox/sandbox_rpc.py
+++ b/packages/python-sdk/e2b/sandbox/sandbox_rpc.py
@@ -186,7 +186,8 @@ class SandboxRpc(BaseModel):
self._process_cleanup.clear()
- for handler in self._waiting_for_replies.values():
+ # .copy() prevents a RuntimeError: dictionary changed size during iteration
+ for handler in self._waiting_for_replies.copy().values():
handler.cancel()
del handler