chroma: set a default timeout of 10 seconds (#5898)

This prevents the `chroma` plugin from hanging the entire import process
if the AcoustID API fails to respond.
This commit is contained in:
Šarūnas Nejus 2025-08-25 23:46:44 +01:00 committed by GitHub
commit e208d4bee3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -98,7 +98,9 @@ def acoustid_match(log, path):
fp = fp.decode()
_fingerprints[path] = fp
try:
res = acoustid.lookup(API_KEY, fp, duration, meta="recordings releases")
res = acoustid.lookup(
API_KEY, fp, duration, meta="recordings releases", timeout=10
)
except acoustid.AcoustidError as exc:
log.debug(
"fingerprint matching {0} failed: {1}",
@ -292,7 +294,7 @@ def submit_items(log, userkey, items, chunksize=64):
"""Submit the current accumulated fingerprint data."""
log.info("submitting {0} fingerprints", len(data))
try:
acoustid.submit(API_KEY, userkey, data)
acoustid.submit(API_KEY, userkey, data, timeout=10)
except acoustid.AcoustidError as exc:
log.warning("acoustid submission error: {0}", exc)
del data[:]

View file

@ -55,6 +55,8 @@ Bug fixes:
- :doc:`plugins/lastgenre`: Fix the issue introduced in Beets 2.3.0 where
non-whitelisted last.fm genres were not canonicalized to parent genres.
:bug:`5930`
- :doc:`plugins/chroma`: AcoustID lookup HTTP requests will now time out after
10 seconds, rather than hanging the entire import process.
For packagers: