fix(gateway): tolerate cancelled channel tasks during shutdown

This commit is contained in:
Xubin Ren
2026-06-22 23:20:45 +08:00
parent f80a78d5a8
commit e624943bac
4 changed files with 66 additions and 0 deletions
+4
View File
@@ -252,6 +252,10 @@ class ChannelManager:
try:
await channel.stop()
logger.info("Stopped {} channel", name)
except asyncio.CancelledError:
if asyncio.current_task() and asyncio.current_task().cancelling():
raise
logger.debug("Channel {} stop task was already cancelled", name)
except Exception:
logger.exception("Error stopping {}", name)
+4
View File
@@ -827,6 +827,10 @@ class WebSocketChannel(BaseChannel):
if self._server_task:
try:
await self._server_task
except asyncio.CancelledError:
if asyncio.current_task() and asyncio.current_task().cancelling():
raise
self.logger.debug("server task was already cancelled during shutdown")
except Exception as e:
self.logger.warning("server task error during shutdown: {}", e)
self._server_task = None