mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 13:18:18 +00:00
Stop code sandbox on request timeout to allow sandbox process restarts
This commit is contained in:
2
.github/workflows/run_evals.yml
vendored
2
.github/workflows/run_evals.yml
vendored
@@ -114,7 +114,7 @@ jobs:
|
||||
|
||||
# Start code sandbox
|
||||
npm install -g pm2
|
||||
npm run ci --prefix terrarium
|
||||
NODE_ENV=production npm run ci --prefix terrarium
|
||||
|
||||
# Wait for server to be ready
|
||||
timeout=120
|
||||
|
||||
@@ -100,7 +100,13 @@ async def run_code(
|
||||
logger.info(f"Executed Code\n----\n{code}\n----\nResult\n----\n{cleaned_result}\n----")
|
||||
yield {query: {"code": code, "results": result}}
|
||||
except asyncio.TimeoutError as e:
|
||||
raise ValueError(f"Failed to run code for {query} with Timeout error: {e}")
|
||||
# Call the sandbox_url/stop GET API endpoint to stop the code sandbox
|
||||
error = f"Failed to run code for {query} with Timeout error: {e}"
|
||||
try:
|
||||
await aiohttp.ClientSession().get(f"{sandbox_url}/stop", timeout=5)
|
||||
except Exception as e:
|
||||
error += f"\n\nFailed to stop code sandbox with error: {e}"
|
||||
raise ValueError(error)
|
||||
except Exception as e:
|
||||
raise ValueError(f"Failed to run code for {query} with error: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user