Files
manage/backend/src/media_library_viewer_api/integrations/.pi-map.index.md
T
Developer ba01ad7c0c perf(qbittorrent): rid incremental sync + shared cache + backoff (stop hanging qBittorrent)
The app was saturating qBittorrent's single-threaded web server and causing
its own Web UI (and the reverse proxy) to hang/504: each of the 3 qBittorrent
widgets fetched /sync/maindata independently, every call was a FULL snapshot
(no rid), and polling was aggressive (5s for speed). For large torrent lists
each snapshot is heavy, so the server queued and Traefik timed out.

QbittorrentClient.maindata now:
- Uses the incremental rid protocol: the first call is a full_update;
  subsequent calls send the last rid and get a small diff that is merged into
  a cached snapshot (full_update replaces; partial_update merges server_state,
  torrents {added/None-removed/..._removed}, categories, tags, trackers).
  Payloads shrink dramatically for large libraries.
- Serves a short-TTL (3s) cached snapshot under a lock, so concurrent widget
  polls collapse onto a single HTTP fetch instead of N.
- Backs off exponentially (capped 30s) on repeated failure, serving the last
  good snapshot when available, so a struggling qBittorrent isn't hammered
  further. Returns a shallow race-safe copy of the snapshot per call.

Also slow the speed widget poll from 5s -> 15s (backend widget-kind +
frontend registry) for ~3x fewer calls.

Tests: rid full+partial merge, cache collapses within-TTL calls, backoff
skips the network after failure and serves stale. 393/393 backend + 180/180
frontend tests pass; ruff + tsc + ESLint clean.
2026-07-12 12:20:05 +00:00

896 B

backend/src/media_library_viewer_api/integrations (index)

dir: backend/src/media_library_viewer_api/integrations

role

Provides pluggable external service integrations (e.g., Alertmanager, Jellyfin, Prometheus, qBittorrent) with standardized configuration, connection testing, and widget definitions for a monitoring dashboard.

parent

index: backend/src/media_library_viewer_api/.pi-map.index.md map: backend/src/media_library_viewer_api/.pi-map.md

children

files

  • __init__.py
  • alertmanager.py
  • authentik.py
  • backups.py
  • base.py
  • jellyfin.py
  • nextcloud.py
  • prometheus.py
  • qbittorrent.py
  • registry.py
  • ssh_tasks.py

index: backend/src/media_library_viewer_api/integrations/.pi-map.index.md map: backend/src/media_library_viewer_api/integrations/.pi-map.md

workflows

  • change integrations behavior read: __init__.py, alertmanager.py, authentik.py

dirty