Skip to content

Commit 9d6cb68

Browse files
fix: Handle asyncio.cancellederror and raise to propagate back (#293)
# Description Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Follow the [`CONTRIBUTING` Guide](https://github.com/a2aproject/a2a-python/blob/main/CONTRIBUTING.md). - [ ] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [ ] Ensure the tests and linter pass (Run `nox -s format` from the repository root to format) - [ ] Appropriate docs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕
1 parent 24f2eb0 commit 9d6cb68

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
@@ -162,6 +163,12 @@ async def async_wrapper(*args, **kwargs) -> Any:
162163
span.set_status(StatusCode.OK)
163164
return result
164165

166+
# asyncio.CancelledError extends from BaseException
167+
except asyncio.CancelledError as ce:
168+
exception = None
169+
logger.debug(f'CancelledError in span {actual_span_name}')
170+
span.record_exception(ce)
171+
raise
165172
except Exception as e:
166173
exception = e
167174
span.record_exception(e)

0 commit comments

Comments
 (0)