Update retry.py

This commit is contained in:
Nuno Campos
2024-09-18 10:23:52 -07:00
committed by GitHub
parent adf5cb0ff1
commit fd0b52f4ff
+3 -3
View File
@@ -2,7 +2,7 @@ import asyncio
import logging
import random
import time
from typing import Optional
from typing import Optional, Sequence
from langgraph.constants import CONFIG_KEY_RESUMING
from langgraph.errors import GraphInterrupt
@@ -38,7 +38,7 @@ def run_with_retry(
# increment attempts
attempts += 1
# check if we should retry
if isinstance(retry_policy.retry_on, (list, tuple)):
if isinstance(retry_policy.retry_on, Sequence):
if not isinstance(exc, tuple(retry_policy.retry_on)):
raise
elif isinstance(retry_policy.retry_on, type) and issubclass(retry_policy.retry_on, Exception):
@@ -102,7 +102,7 @@ async def arun_with_retry(
# increment attempts
attempts += 1
# check if we should retry
if isinstance(retry_policy.retry_on, (list, tuple)):
if isinstance(retry_policy.retry_on, Sequence):
if not isinstance(exc, tuple(retry_policy.retry_on)):
raise
elif isinstance(retry_policy.retry_on, type) and issubclass(retry_policy.retry_on, Exception):