mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Update the retry_on_closed_resource decorator to retry on all errors
Retrying only on closed_resource error is not enough to be reliable for production environments due to the other network errors that may occur -- remote protocol error, read timeout, etc. We will update this to retry on all errors. Since it is only a one-time retry, it should not affect latency significantly. Fixes https://github.com/google/adk-python/issues/2561. PiperOrigin-RevId: 831153803
This commit is contained in:
committed by
Copybara-Service
parent
999af55880
commit
3674fbbe8f
@@ -32,7 +32,7 @@ pytestmark = pytest.mark.skipif(
|
||||
# Import dependencies with version checking
|
||||
try:
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import MCPSessionManager
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import retry_on_errors
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import retry_on_closed_resource
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import SseConnectionParams
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
|
||||
@@ -44,7 +44,7 @@ except ImportError as e:
|
||||
pass
|
||||
|
||||
MCPSessionManager = DummyClass
|
||||
retry_on_errors = lambda x: x
|
||||
retry_on_closed_resource = lambda x: x
|
||||
SseConnectionParams = DummyClass
|
||||
StdioConnectionParams = DummyClass
|
||||
StreamableHTTPConnectionParams = DummyClass
|
||||
@@ -375,12 +375,12 @@ class TestMCPSessionManager:
|
||||
assert "Close error 1" in error_output
|
||||
|
||||
|
||||
def test_retry_on_errors_decorator():
|
||||
"""Test the retry_on_errors decorator."""
|
||||
def test_retry_on_closed_resource_decorator():
|
||||
"""Test the retry_on_closed_resource decorator."""
|
||||
|
||||
call_count = 0
|
||||
|
||||
@retry_on_errors
|
||||
@retry_on_closed_resource
|
||||
async def mock_function(self):
|
||||
nonlocal call_count
|
||||
call_count += 1
|
||||
|
||||
Reference in New Issue
Block a user