A programming framework for agentic AI
Dont print exceptions for cancelled errors (#119)
Jack Gerritsbb4bb5bd1449
diff --git a/python/src/agnext/application/_single_threaded_agent_runtime.py b/python/src/agnext/application/_single_threaded_agent_runtime.pyindex 83f101074..564807162 100644--- a/python/src/agnext/application/_single_threaded_agent_runtime.py+++ b/python/src/agnext/application/_single_threaded_agent_runtime.py@@ -2,7 +2,7 @@ import asyncioimport inspectimport loggingimport threading-from asyncio import Future+from asyncio import CancelledError, Futurefrom collections import defaultdictfrom collections.abc import Sequencefrom dataclasses import dataclass@@ -281,11 +281,13 @@ class SingleThreadedAgentRuntime(AgentRuntime):try:_all_responses = await asyncio.gather(*responses)- except BaseException:+ except BaseException as e:+ # Ignore cancelled errors from logs+ if isinstance(e, CancelledError):+ returnlogger.error("Error processing publish message", exc_info=True)- return-- self._outstanding_tasks.decrement()+ finally:+ self._outstanding_tasks.decrement()# TODO if responses are given for a publishasync def _process_response(self, message_envelope: ResponseMessageEnvelope) -> None: