fix: split HTTP connect/read timeouts (Jellyfin build + qBit stats)

Every HTTP client passed an integer timeout to requests, applying the same
value to BOTH connect and read phases. A slow Jellyfin /Items page or qBit
/sync/maindata blew through the 10s read budget → ReadTimeoutError. Split
into a (connect=5s, read=60s default) tuple via shared http_timeout() helper.
The media index build worker uses a 180s read floor. Existing services with
low timeout_seconds benefit from bumping to 60+.
This commit is contained in:
Developer
2026-07-10 11:43:07 +00:00
parent 9bc8fab971
commit 044d386ac7
17 changed files with 152 additions and 29 deletions
@@ -115,7 +115,7 @@ class MetricSource:
grafana_url = str(service.config.get("grafana_url") or "").rstrip("/")
api_key = str(service.secrets.get("grafana_api_key") or "")
datasource_uid = str(service.config.get("datasource_uid") or "prometheus")
timeout = int(service.config.get("timeout_seconds") or 10)
timeout = int(service.config.get("timeout_seconds") or 60)
if widget_kind == "chart":
return await self._fetch_chart(grafana_url, api_key, datasource_uid, timeout, config)
if widget_kind == "gauge":
@@ -277,7 +277,7 @@ class AlertmanagerWidgetSource:
if service is None:
return {"error": "Alertmanager widget is missing its service"}
base_url = str(service.config.get("base_url") or "").rstrip("/")
timeout = int(service.config.get("timeout_seconds") or 5)
timeout = int(service.config.get("timeout_seconds") or 60)
severity_filter = config.get("severity_filter") or None
headers: dict[str, str] = {}
api_key = str(service.secrets.get("api_key") or "")
@@ -316,7 +316,7 @@ class JellyfinWidgetSource:
return {"error": "Jellyfin widget is missing its service"}
base_url = str(service.config.get("base_url") or "")
api_key = str(service.secrets.get("api_key") or "")
timeout = int(service.config.get("timeout_seconds") or 10)
timeout = int(service.config.get("timeout_seconds") or 60)
client = await asyncio.wait_for(
asyncio.to_thread(JellyfinClient, base_url, api_key, timeout),
timeout=timeout,
@@ -396,7 +396,7 @@ class QbittorrentWidgetSource:
base_url = str(service.config.get("base_url") or "")
username = str(service.secrets.get("username") or "")
password = str(service.secrets.get("password") or "")
timeout = int(service.config.get("timeout_seconds") or 10)
timeout = int(service.config.get("timeout_seconds") or 60)
if not base_url or not username or not password:
return {"error": "qBittorrent service is missing base_url, username, or password"}