fix: preserve real cancellation in MCP paths
This commit is contained in:
@@ -81,6 +81,7 @@ from nanobot.session.manager import (
|
||||
replay_max_messages_for_context,
|
||||
)
|
||||
from nanobot.triggers.local_turns import LocalTriggerTurnCoordinator
|
||||
from nanobot.utils.cancellation import task_is_cancelling
|
||||
from nanobot.utils.document import extract_documents, reference_non_image_attachments
|
||||
from nanobot.utils.helpers import image_placeholder_text
|
||||
from nanobot.utils.helpers import truncate_text as truncate_text_fn
|
||||
@@ -998,8 +999,11 @@ class AgentLoop:
|
||||
except asyncio.CancelledError:
|
||||
# Preserve real task cancellation so shutdown can complete cleanly.
|
||||
# Only ignore non-task CancelledError signals that may leak from integrations.
|
||||
if not self._running or asyncio.current_task().cancelling():
|
||||
if not self._running or task_is_cancelling():
|
||||
raise
|
||||
logger.warning(
|
||||
"Ignoring leaked CancelledError while consuming inbound messages"
|
||||
)
|
||||
continue
|
||||
except Exception as e:
|
||||
logger.warning("Error consuming inbound message: {}, continuing...", e)
|
||||
|
||||
Reference in New Issue
Block a user