Merge pull request #663 from langchain-ai/nc/13jun/adjust-default-error-policy

Adjust default error policy
This commit is contained in:
Nuno Campos
2024-06-13 09:24:43 -07:00
committed by GitHub
3 changed files with 10 additions and 4 deletions
+8 -2
View File
@@ -13,6 +13,8 @@ logger = logging.getLogger(__name__)
def default_retry_on(exc: Exception) -> bool:
if isinstance(exc, ConnectionError):
return True
if isinstance(
exc,
(
@@ -24,6 +26,10 @@ def default_retry_on(exc: Exception) -> bool:
NameError,
SyntaxError,
RuntimeError,
ReferenceError,
StopIteration,
StopAsyncIteration,
OSError,
),
):
return False
@@ -90,7 +96,7 @@ def run_with_retry(
)
# log the retry
logger.info(
f"Retrying task {task.name} after {interval:.2f} seconds (attempt {attempts})"
f"Retrying task {task.name} after {interval:.2f} seconds (attempt {attempts}) after {exc.__class__.__name__} {exc}"
)
@@ -138,5 +144,5 @@ async def arun_with_retry(
)
# log the retry
logger.info(
f"Retrying task {task.name} after {interval:.2f} seconds (attempt {attempts})"
f"Retrying task {task.name} after {interval:.2f} seconds (attempt {attempts}) after {exc.__class__.__name__} {exc}"
)
+1 -1
View File
@@ -842,7 +842,7 @@ def test_invoke_checkpoint(mocker: MockerFixture) -> None:
pass
else:
errored_once = True
raise OSError("I will be retried")
raise ConnectionError("I will be retried")
if input > 10:
raise ValueError("Input is too large")
return input
+1 -1
View File
@@ -758,7 +758,7 @@ async def test_invoke_checkpoint(mocker: MockerFixture) -> None:
pass
else:
errored_once = True
raise OSError("I will be retried")
raise ConnectionError("I will be retried")
if input > 10:
raise ValueError("Input is too large")
return input