1
0

[kimi] Break up _dispatch_via_gitea() into helper functions (#1136) (#1183)

This commit is contained in:
2026-03-23 21:40:17 +00:00
parent 74bf0606a9
commit 7aa48b4e22
26 changed files with 195 additions and 115 deletions

View File

@@ -18,7 +18,6 @@ from __future__ import annotations
import asyncio
import json
import logging
from contextlib import asynccontextmanager
from typing import Any
logger = logging.getLogger(__name__)
@@ -81,7 +80,7 @@ class GABSClient:
)
self._connected = True
logger.info("GABS connected at %s:%s", self._host, self._port)
except (OSError, asyncio.TimeoutError) as exc:
except (TimeoutError, OSError) as exc:
logger.warning(
"GABS unavailable at %s:%s — Bannerlord agent will degrade: %s",
self._host,
@@ -100,7 +99,7 @@ class GABSClient:
self._connected = False
logger.debug("GABS connection closed")
async def __aenter__(self) -> "GABSClient":
async def __aenter__(self) -> GABSClient:
await self.connect()
return self
@@ -139,10 +138,8 @@ class GABSClient:
self._writer.write(payload.encode())
await asyncio.wait_for(self._writer.drain(), timeout=self._timeout)
raw = await asyncio.wait_for(
self._reader.readline(), timeout=self._timeout
)
except (OSError, asyncio.TimeoutError) as exc:
raw = await asyncio.wait_for(self._reader.readline(), timeout=self._timeout)
except (TimeoutError, OSError) as exc:
self._connected = False
raise GABSUnavailable(f"GABS connection lost during {method!r}: {exc}") from exc