mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Fix MCPToolset crashing with anyio.BrokenResourceError
Add error handling for broken resource error so that it retries. Fixes https://github.com/google/adk-python/issues/2769. Co-authored-by: Kathy Wu <wukathy@google.com> PiperOrigin-RevId: 829146121
This commit is contained in:
committed by
Copybara-Service
parent
c0be1df052
commit
8e0648df23
@@ -126,9 +126,10 @@ def retry_on_closed_resource(func):
|
|||||||
async def wrapper(self, *args, **kwargs):
|
async def wrapper(self, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return await func(self, *args, **kwargs)
|
return await func(self, *args, **kwargs)
|
||||||
except anyio.ClosedResourceError:
|
except (anyio.ClosedResourceError, anyio.BrokenResourceError):
|
||||||
# Simply retry the function - create_session will handle
|
# If the session connection is closed or unusable, we will retry the
|
||||||
# detecting and replacing disconnected sessions
|
# function to reconnect to the server. create_session will handle
|
||||||
|
# detecting and replacing disconnected sessions.
|
||||||
logger.info('Retrying %s due to closed resource', func.__name__)
|
logger.info('Retrying %s due to closed resource', func.__name__)
|
||||||
return await func(self, *args, **kwargs)
|
return await func(self, *args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user