Skip to content

Commit

Permalink
minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
humpydonkey committed Jul 2, 2024
1 parent 686b8c6 commit fb51bf7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vision_agent/utils/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

load_dotenv()
_LOGGER = logging.getLogger(__name__)
_SESSION_TIMEOUT = 600 # 10 minutes
_SESSION_TIMEOUT = 300 # 5 minutes


class MimeType(str, Enum):
Expand Down Expand Up @@ -445,6 +445,9 @@ def restart_kernel(self) -> None:
retry=tenacity.retry_if_exception_type(TimeoutError),
)
def exec_cell(self, code: str) -> Execution:
if not self.interpreter.is_running():
raise ConnectionResetError("Remote sandbox is not closed unexpectedly. Please retry the operation.")
self.interpreter.set_timeout(_SESSION_TIMEOUT) # Extend the life of the sandbox
execution = self.interpreter.notebook.exec_cell(code, timeout=self.timeout)
return Execution.from_e2b_execution(execution)

Expand Down Expand Up @@ -473,7 +476,7 @@ def _new_e2b_interpreter_impl(*args, **kwargs) -> E2BCodeInterpreterImpl: # typ


class LocalCodeInterpreter(CodeInterpreter):
def __init__(self, timeout: int = 600) -> None:
def __init__(self, timeout: int = _SESSION_TIMEOUT) -> None:
super().__init__(timeout=timeout)
self.nb = nbformat.v4.new_notebook()
self.nb_client = NotebookClient(self.nb, timeout=self.timeout)
Expand Down

0 comments on commit fb51bf7

Please sign in to comment.