Bound Space model sync startup wait (#2248)

* fix(modelmgr): bound Space model sync startup wait

* style(provider): format model manager
This commit is contained in:
huanghuoguoguo
2026-06-18 14:00:33 +00:00
committed by GitHub
parent 6b15a732e4
commit 5fe63ce822
2 changed files with 34 additions and 1 deletions
+11 -1
View File
@@ -1,5 +1,6 @@
from __future__ import annotations
import asyncio
import sqlalchemy
import traceback
@@ -84,8 +85,17 @@ class ModelManager:
self.ap.logger.info('LangBot Space Models service is disabled, skipping sync.')
return
sync_timeout = space_config.get('models_sync_timeout')
try:
await self.sync_new_models_from_space()
if sync_timeout:
await asyncio.wait_for(
self.sync_new_models_from_space(),
timeout=float(sync_timeout),
)
else:
await self.sync_new_models_from_space()
except asyncio.TimeoutError:
self.ap.logger.warning(f'LangBot Space model sync timed out after {sync_timeout}s, skipping startup sync.')
except Exception as e:
self.ap.logger.warning('Failed to sync new models from LangBot Space, model list may not be updated.')
self.ap.logger.warning(f' - Error: {e}')