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 Novak27da7a6d744b
diff --git a/packages/python-sdk/e2b/session/session_connection.py b/packages/python-sdk/e2b/session/session_connection.py
index f1d6a6e31..32f08193d 100644
--- a/packages/python-sdk/e2b/session/session_connection.py
+++ b/packages/python-sdk/e2b/session/session_connection.py
@@ -9,7 +9,7 @@ from time import sleep
from typing import Any, Callable, List, Literal, Optional, Union
from pydantic import BaseModel
-from urllib3.exceptions import MaxRetryError, ConnectTimeoutError
+from urllib3.exceptions import ReadTimeoutError, MaxRetryError, ConnectTimeoutError
from e2b.api import client, configuration, exceptions, models
from e2b.constants import (
@@ -188,9 +188,13 @@ class SessionConnection:
self._process_cleanup.append(self._refreshing_task.cancel)
self._process_cleanup.append(lambda: shutdown_executor(executor))
- except MaxRetryError as e:
+ except ReadTimeoutError as e:
logger.error(f"Failed to acquire session")
self._close()
+ raise TimeoutException(
+ f"Failed to acquire session: {e}",
+ ) from e
+ except MaxRetryError as e:
if isinstance(e.reason, ConnectTimeoutError):
raise TimeoutException(
f"Failed to acquire session: {e}",
diff --git a/packages/python-sdk/poetry.lock b/packages/python-sdk/poetry.lock
index 233154dc7..fff97a4f6 100644
--- a/packages/python-sdk/poetry.lock
+++ b/packages/python-sdk/poetry.lock
@@ -816,6 +816,21 @@ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""}
[package.extras]
testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
+[[package]]
+name = "pytest-dotenv"
+version = "0.5.2"
+description = "A py.test plugin that parses environment files before running tests"
+optional = false
+python-versions = "*"
+files = [
+ {file = "pytest-dotenv-0.5.2.tar.gz", hash = "sha256:2dc6c3ac6d8764c71c6d2804e902d0ff810fa19692e95fe138aefc9b1aa73732"},
+ {file = "pytest_dotenv-0.5.2-py3-none-any.whl", hash = "sha256:40a2cece120a213898afaa5407673f6bd924b1fa7eafce6bda0e8abffe2f710f"},
+]
+
+[package.dependencies]
+pytest = ">=5.0.0"
+python-dotenv = ">=0.9.1"
+
[[package]]
name = "pytest-xdist"
version = "3.3.1"
@@ -1104,4 +1119,4 @@ multidict = ">=4.0"
[metadata]
lock-version = "2.0"
python-versions = "^3.8"
-content-hash = "58881bb28e738261cc2a33f2f7c3b5e1a265a45fb9551a9e4dd0f4d26247db86"
+content-hash = "92ceca04431e9bf42805e2b4228eaf0859b25e42ee3e6f4569bdbdf36751692c"
diff --git a/packages/python-sdk/pyproject.toml b/packages/python-sdk/pyproject.toml
index e977d1f00..e64e14f33 100644
--- a/packages/python-sdk/pyproject.toml
+++ b/packages/python-sdk/pyproject.toml
@@ -27,6 +27,7 @@ pytest = "^7.4.0"
pytest-xdist = "^3.3.1"
psycopg2 = "^2.9.7"
python-dotenv = "^1.0.0"
+pytest-dotenv = "^0.5.2"
[build-system]
requires = ["poetry-core"]