Fix WebUI startup blocking on slow gateway routes
This commit is contained in:
@@ -107,7 +107,7 @@ class WebUISettingsRouter:
|
||||
if path == "/api/settings/network-safety/update":
|
||||
return self._handle_settings_network_safety_update(request)
|
||||
if path == "/api/settings/cli-apps":
|
||||
return self._handle_settings_cli_apps(request)
|
||||
return await self._handle_settings_cli_apps(request)
|
||||
if path == "/api/settings/cli-apps/install":
|
||||
return await self._handle_settings_cli_apps_action(request, "install")
|
||||
if path == "/api/settings/cli-apps/update":
|
||||
@@ -299,11 +299,20 @@ class WebUISettingsRouter:
|
||||
return self._error_response(e.status, e.message)
|
||||
return self._json_response(self._with_restart_state(payload, section="runtime"))
|
||||
|
||||
def _handle_settings_cli_apps(self, request: WsRequest) -> Response:
|
||||
async def _handle_settings_cli_apps(self, request: WsRequest) -> Response:
|
||||
if not self._authorized(request):
|
||||
return self._unauthorized()
|
||||
query = self._query(request)
|
||||
installed_only = (query.get("installed_only") or [""])[0].lower() in {
|
||||
"1",
|
||||
"true",
|
||||
"yes",
|
||||
}
|
||||
try:
|
||||
payload = cli_apps_payload()
|
||||
if installed_only:
|
||||
payload = await asyncio.to_thread(cli_apps_payload, installed_only=True)
|
||||
else:
|
||||
payload = await asyncio.to_thread(cli_apps_payload)
|
||||
except Exception:
|
||||
self.logger.exception("failed to load CLI Apps payload")
|
||||
return self._error_response(500, "failed to load CLI Apps")
|
||||
|
||||
Reference in New Issue
Block a user