From 442c7b615344ea2eabbd2eaebdee1949ace58ea1 Mon Sep 17 00:00:00 2001 From: Debanjum Date: Sat, 17 May 2025 17:07:31 -0700 Subject: [PATCH] Retry running code on more request exception --- src/khoj/processor/tools/run_code.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/khoj/processor/tools/run_code.py b/src/khoj/processor/tools/run_code.py index e188da05..535edd0e 100644 --- a/src/khoj/processor/tools/run_code.py +++ b/src/khoj/processor/tools/run_code.py @@ -9,8 +9,8 @@ from pathlib import Path from typing import Any, Callable, List, NamedTuple, Optional import aiohttp +import httpx from asgiref.sync import sync_to_async -from httpx import RemoteProtocolError from tenacity import ( before_sleep_log, retry, @@ -192,7 +192,9 @@ async def generate_python_code( | retry_if_exception_type(aiohttp.ClientTimeout) | retry_if_exception_type(asyncio.TimeoutError) | retry_if_exception_type(ConnectionError) - | retry_if_exception_type(RemoteProtocolError) + | retry_if_exception_type(httpx.RemoteProtocolError) + | retry_if_exception_type(httpx.NetworkError) + | retry_if_exception_type(httpx.TimeoutException) ), wait=wait_random_exponential(min=1, max=5), stop=stop_after_attempt(3),