Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Suppress ws reconnect logs by default; Reduce backoff

Tomas Valentaa9da9a714a79
diff --git a/.changeset/rotten-months-cheat.md b/.changeset/rotten-months-cheat.md
new file mode 100644
index 000000000..d5e541cf1
--- /dev/null
+++ b/.changeset/rotten-months-cheat.md
@@ -0,0 +1,5 @@
+---
+"@e2b/python-sdk": patch
+---
+
+Supress ws reconnect logs by default; Change reconnect backoff
diff --git a/packages/python-sdk/e2b/sandbox/websocket_client.py b/packages/python-sdk/e2b/sandbox/websocket_client.py
index c87052453..4a03c78aa 100644
--- a/packages/python-sdk/e2b/sandbox/websocket_client.py
+++ b/packages/python-sdk/e2b/sandbox/websocket_client.py
@@ -7,7 +7,7 @@ from queue import Queue
from threading import Event
from typing import Any, Callable, List, Optional
-from websockets import WebSocketClientProtocol, connect
+from websockets.legacy.client import WebSocketClientProtocol, connect
from websockets.exceptions import ConnectionClosed
from websockets.typing import Data
@@ -63,10 +63,21 @@ class WebSocket:
async def _connect(self):
logger.debug(f"WebSocket connecting to {self.url}")
- websocket_connector = connect(self.url, max_size=None, max_queue=None)
+
+ ws_logger = logger.getChild("websockets.client")
+ ws_logger.setLevel(logging.ERROR)
+
+ websocket_connector = connect(
+ self.url,
+ max_size=None,
+ max_queue=None,
+ logger=ws_logger,
+ )
+
websocket_connector.BACKOFF_MIN = 1
websocket_connector.BACKOFF_FACTOR = 1
- websocket_connector.BACKOFF_INITIAL = 0.4
+ websocket_connector.BACKOFF_INITIAL = 0.3 # type: ignore
+
async for websocket in websocket_connector:
try:
self._ws = websocket