Skip to content

Commit c550f48

Browse files
Handle asyncio.cancellederror and raise it so it propagates back
1 parent 07e9b84 commit c550f48

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/a2a/utils/telemetry.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def internal_method(self):
5353
```
5454
"""
5555

56+
import asyncio
5657
import functools
5758
import inspect
5859
import logging
@@ -167,6 +168,12 @@ async def async_wrapper(*args, **kwargs) -> Any:
167168
span.record_exception(e)
168169
span.set_status(StatusCode.ERROR, description=str(e))
169170
raise
171+
# asyncio.CancelledError extends from BaseException
172+
except asyncio.CancelledError as ce:
173+
logger.debug(f'CancelledError in span {actual_span_name}')
174+
span.record_exception(ce)
175+
span.set_status(StatusCode.ERROR, description=str(ce))
176+
raise
170177
finally:
171178
if attribute_extractor:
172179
try:

0 commit comments

Comments
 (0)