mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-31 12:19:58 +02:00
Merge pull request #663 from langchain-ai/nc/13jun/adjust-default-error-policy
Adjust default error policy
This commit is contained in:
@@ -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}"
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user