|
13 | 13 | from e2b_code_interpreter import Sandbox |
14 | 14 | from strenum import StrEnum |
15 | 15 | from pathlib import Path |
16 | | -import tempfile |
17 | 16 | import time |
18 | 17 | from typing import Optional, Type |
19 | 18 | from types import TracebackType |
@@ -261,15 +260,21 @@ def __init__( |
261 | 260 | self.sb.files.write(f["dest"].name, content) # type: ignore |
262 | 261 |
|
263 | 262 | def exec_run_with_timeout(self, command: str) -> tuple[str, bool, float]: |
264 | | - """Execute command on E2B sandbox""" |
| 263 | + """Execute command on E2B sandbox |
| 264 | + For timeouts, we could maybe use the error code or check whether the |
| 265 | + sandbox is still alive. |
| 266 | +
|
| 267 | + The exit code is given by: result.exit_code |
| 268 | +
|
| 269 | + For now, we can just check if the sandbox is still alive. |
| 270 | + """ |
265 | 271 | # TODO: setup timeout |
266 | 272 | start_time = time.time() |
267 | | - result = self.sb.commands.run(command) |
268 | | - return_code = result.exit_code |
| 273 | + result = self.sb.commands.run(command, timeout=0) |
269 | 274 | for fname in self.files_to_collect: |
270 | 275 | with (self.log_dir / fname).open("w") as f: |
271 | 276 | f.write(self.sb.files.read(f"testbed/{fname}")) |
272 | | - timed_out = False # TODO: figure this out |
| 277 | + timed_out = self.sb.is_running |
273 | 278 | end_time = time.time() |
274 | 279 | return result.stderr, timed_out, end_time - start_time |
275 | 280 |
|
|
0 commit comments