Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Fix timeout test

Jakub Novakd11978ff9a82
diff --git a/packages/python-sdk/e2b/session/session_connection.py b/packages/python-sdk/e2b/session/session_connection.py
index 63764a824..8149c2898 100644
--- a/packages/python-sdk/e2b/session/session_connection.py
+++ b/packages/python-sdk/e2b/session/session_connection.py
@@ -120,7 +120,7 @@ class SessionConnection:
"""
Close the session and unsubscribe from all the subscriptions.
"""
- if self._is_open:
+ if self._is_open and self._session:
logger.info(
f"Closing session {self._session.code_snippet_id} (id: {self._session.session_id})"
)
diff --git a/packages/python-sdk/tests/test_timeout.py b/packages/python-sdk/tests/test_timeout.py
index e77e85d94..79dc1e9dd 100644
--- a/packages/python-sdk/tests/test_timeout.py
+++ b/packages/python-sdk/tests/test_timeout.py
@@ -9,7 +9,7 @@ E2B_API_KEY = getenv("E2B_API_KEY")
async def test_create_session_timeout():
with pytest.raises(asyncio.TimeoutError):
- await Session.create("Nodejs", api_key=E2B_API_KEY, timeout=0.1)
+ await Session.create("Nodejs", api_key=E2B_API_KEY, timeout=0.01)
async def test_process_timeout():
@@ -17,7 +17,7 @@ async def test_process_timeout():
session = await Session.create("Nodejs", api_key=E2B_API_KEY)
await session.process.start(
"sleep 1",
- timeout=0.1,
+ timeout=0.01,
)
await session.close()
@@ -28,6 +28,6 @@ async def test_filesystem_timeout():
await session.filesystem.write(
"test.txt",
"Hello World",
- timeout=0.1,
+ timeout=0.01,
)
await session.close()