Skip to content

Commit

Permalink
Handle TimeoutError with retry (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
humpydonkey authored Jun 5, 2024
1 parent bfdb16e commit 42455ee
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vision_agent/utils/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ def close(self, *args: Any, **kwargs: Any) -> None:
def restart_kernel(self) -> None:
self.interpreter.notebook.restart_kernel()

@tenacity.retry(
wait=tenacity.wait_exponential_jitter(),
stop=tenacity.stop_after_attempt(2),
retry=tenacity.retry_if_exception_type(TimeoutError),
)
def exec_cell(self, code: str) -> Execution:
execution = self.interpreter.notebook.exec_cell(code, timeout=self.timeout)
return Execution.from_e2b_execution(execution)
Expand Down

0 comments on commit 42455ee

Please sign in to comment.