Skip slskd API calls when known disconnected to prevent timeout spam
When slskd is unreachable, the download status emitter was making two blocking API calls every 2 seconds (0.75s cache TTL), each timing out after 5-10s. With 9 enrichment workers + WebSocket emitters competing for threads, this created enough thread pressure to trigger Werkzeug's "write() before start_response" race condition and crash the process. Fix: check _status_cache (refreshed every 2 min by /status endpoint) before calling slskd. If soulseek is known disconnected, skip both transfers/downloads calls and return empty data. Normal behavior resumes within 2 minutes of slskd recovering.
This commit is contained in:
parent
8e41feaade
commit
de5e3f6b3f
1 changed files with 8 additions and 2 deletions
|
|
@ -1855,8 +1855,13 @@ def get_cached_transfer_data():
|
|||
# Cache expired or empty, fetch new data
|
||||
live_transfers_lookup = {}
|
||||
try:
|
||||
# Skip Soulseek API call if we already know it's disconnected (avoid timeout spam)
|
||||
soulseek_known_down = not _status_cache.get('soulseek', {}).get('connected', True)
|
||||
|
||||
# First, get Soulseek downloads from API
|
||||
transfers_data = run_async(soulseek_client._make_request('GET', 'transfers/downloads'))
|
||||
transfers_data = None
|
||||
if not soulseek_known_down:
|
||||
transfers_data = run_async(soulseek_client._make_request('GET', 'transfers/downloads'))
|
||||
if transfers_data:
|
||||
all_transfers = []
|
||||
for user_data in transfers_data:
|
||||
|
|
@ -1872,8 +1877,9 @@ def get_cached_transfer_data():
|
|||
live_transfers_lookup[key] = transfer
|
||||
|
||||
# Also add YouTube/Tidal/Qobuz downloads (through orchestrator)
|
||||
# Note: get_all_downloads() also hits slskd API — skip if we know it's down
|
||||
try:
|
||||
all_downloads = run_async(soulseek_client.get_all_downloads())
|
||||
all_downloads = run_async(soulseek_client.get_all_downloads()) if not soulseek_known_down else []
|
||||
for download in all_downloads:
|
||||
# Only add streaming source downloads (Soulseek ones are already in the lookup)
|
||||
if download.username in ('youtube', 'tidal', 'qobuz', 'hifi', 'deezer_dl'):
|
||||
|
|
|
|||
Loading…
Reference in a new issue