From 24a482c71a1398a45e8d57ca2b2e6b343764a870 Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com> Date: Wed, 16 Aug 2023 13:44:52 -0300 Subject: [PATCH] Added checking for CancelledError in YAML runner (#28693) --- scripts/py_matter_yamltests/matter_yamltests/runner.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/py_matter_yamltests/matter_yamltests/runner.py b/scripts/py_matter_yamltests/matter_yamltests/runner.py index c819eea79d9a56..472d3cd8fa8203 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/runner.py +++ b/scripts/py_matter_yamltests/matter_yamltests/runner.py @@ -16,6 +16,7 @@ import asyncio import time from abc import ABC, abstractmethod +from asyncio import CancelledError from dataclasses import dataclass, field from .adapter import TestAdapter @@ -144,7 +145,7 @@ async def run(self, parser_builder_config: TestParserBuilderConfig, runner_confi continue result = await self._run_with_timeout(parser, runner_config) - if isinstance(result, Exception): + if isinstance(result, Exception) or isinstance(result, CancelledError): raise (result) elif not result: return False @@ -160,7 +161,7 @@ async def _run_with_timeout(self, parser: TestParser, config: TestRunnerConfig): try: await self.start() status = await asyncio.wait_for(self._run(parser, config), parser.timeout) - except Exception as exception: + except (Exception, CancelledError) as exception: status = exception finally: await self.stop()