Skip to content

chroma: set a default timeout of 10 seconds #5898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

9999years
Copy link
Contributor

@9999years 9999years commented Jul 28, 2025

Description

This prevents the chroma plugin from hanging the entire import process if the AcoustID API fails to respond.

TODO: Configurable timeouts

To Do

  • Documentation. (If you've added a new command-line flag, for example, find the appropriate page under docs/ to describe it.)
  • Changelog. (Add an entry to docs/changelog.rst to the bottom of one of the lists near the top of the document.)
  • Tests. (Very much encouraged but not strictly required.)

Copy link

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@e3574a7). Learn more about missing BASE report.

Files with missing lines Patch % Lines
beetsplug/chroma.py 0.00% 2 Missing ⚠️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@snejus
Copy link
Member

snejus commented Aug 2, 2025

Looks good to me, just need a changelog note. Is there a reason this is a draft?

@9999years
Copy link
Contributor Author

@snejus Thanks, that's good to hear! I kinda wanted to write a test for it and/or make it configurable. It's OK as a patch for me to run but I'd like it to be configurable for others...

@snejus
Copy link
Member

snejus commented Aug 2, 2025

I think very few people would every want to adjust this timeout, probably... I think your adjustment goes in line with this previous PR: #5262, where we added timeout argument to every requests invocation. Thus, I'm happy with what you have here plus a note in the changelog :)

@9999years 9999years marked this pull request as ready for review August 2, 2025 23:38
@Copilot Copilot AI review requested due to automatic review settings August 2, 2025 23:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a default timeout of 10 seconds to AcoustID API calls in the chroma plugin to prevent the import process from hanging when the AcoustID API fails to respond.

  • Adds 10-second timeout to acoustid.lookup() calls during fingerprint matching
  • Adds 10-second timeout to acoustid.submit() calls during fingerprint submission
  • Updates changelog to document this bug fix

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
beetsplug/chroma.py Adds timeout parameter to acoustid.lookup() and acoustid.submit() API calls
docs/changelog.rst Documents the addition of HTTP request timeouts for AcoustID lookups

@@ -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
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded timeout value of 10 seconds should be extracted as a module-level constant to improve maintainability and consistency, since it's used in multiple places.

Suggested change
API_KEY, fp, duration, meta="recordings releases", timeout=10
API_KEY, fp, duration, meta="recordings releases", timeout=ACOUSTID_TIMEOUT

Copilot uses AI. Check for mistakes.

@@ -292,7 +294,7 @@ def submit_chunk():
"""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)
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded timeout value of 10 seconds should be extracted as a module-level constant to improve maintainability and consistency, since it's used in multiple places.

Suggested change
acoustid.submit(API_KEY, userkey, data, timeout=10)
acoustid.submit(API_KEY, userkey, data, timeout=ACOUSTID_SUBMIT_TIMEOUT)

Copilot uses AI. Check for mistakes.

TODO: Configurable timeouts :)
@snejus snejus enabled auto-merge August 6, 2025 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants