chroma: use force_fpcalc=True to prevent fd exhaustion - #6928
Open
slmingol wants to merge 2 commits into
Open
Conversation
|
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. |
Contributor
There was a problem hiding this comment.
Pull request overview
grug see PR try fix fd leak in chroma fingerprint by skip audioread/GStreamer path and always go through fpcalc via force_fpcalc=True. this fit beetsplug/chroma.py fingerprint + acoustid lookup path.
Changes:
- pass
force_fpcalc=Trueinacoustid_match()fingerprint generation - pass
force_fpcalc=Trueinfingerprint_item()fingerprint generation
Suppressed comments (1)
beetsplug/chroma.py:445
- grug see new force_fpcalc kwarg here too. if pyacoustid old, TypeError bubble up and crash fingerprint command/import. grug want catch TypeError and print upgrade hint.
_, fp = acoustid.fingerprint_file(util.syspath(item.path), force_fpcalc=True)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| """ | ||
| try: | ||
| duration, fp = acoustid.fingerprint_file(util.syspath(path)) | ||
| duration, fp = acoustid.fingerprint_file(util.syspath(path), force_fpcalc=True) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6928 +/- ##
==========================================
+ Coverage 75.88% 75.96% +0.07%
==========================================
Files 164 164
Lines 21448 21448
Branches 3381 3381
==========================================
+ Hits 16275 16292 +17
+ Misses 4369 4351 -18
- Partials 804 805 +1
🚀 New features to boost your workflow:
|
slmingol
force-pushed
the
fix/chroma-fd-leak-force-fpcalc
branch
2 times, most recently
from
August 16, 2026 05:07
2750b67 to
686d29a
Compare
audioread's GStreamer backend leaks file descriptors when fingerprinting
fails or GStreamer encounters an error. Across thousands of files this
exhausts the process fd limit:
OSError: [Errno 24] No file descriptors available
pyacoustid.fingerprint_file() accepts force_fpcalc=True (added in
pyacoustid 1.2.0) which routes fingerprinting through the fpcalc binary,
bypassing audioread/GStreamer entirely. fpcalc is already a hard dependency
of the chroma plugin so no new requirements are introduced.
Both call sites are updated. A TypeError guard is added at each site to
handle pyacoustid versions older than 1.2.0 that do not accept the kwarg.
Fixes beetbox#5171
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add TestAcoustidMatch: - assert force_fpcalc=True is passed to fingerprint_file - assert TypeError from old pyacoustid is caught, not raised Add TestFingerprintItem: - assert TypeError from old pyacoustid in fingerprint_item returns None Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
slmingol
force-pushed
the
fix/chroma-fd-leak-force-fpcalc
branch
from
August 16, 2026 13:03
686d29a to
b7728b6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The chroma plugin leaks file descriptors when fingerprinting via audioread's GStreamer backend. When fingerprinting fails or GStreamer encounters an error, the pipeline socket is left open. Across thousands of files this exhausts the process fd limit:
```
OSError: [Errno 24] No file descriptors available
```
This causes `beet import` to crash mid-run on large libraries. Raising `ulimit -n` only delays the inevitable — the leak is unbounded.
Reported in #5171.
Fix
`pyacoustid.fingerprint_file()` accepts a `force_fpcalc=True` parameter (added in pyacoustid 1.2.0) that routes fingerprinting through the `fpcalc` binary, bypassing audioread and GStreamer entirely. `fpcalc` is already a hard dependency of the chroma plugin, so no new requirements are introduced.
Both call sites in `chroma.py` are updated.
Testing
Verified against a library of ~10,000 albums where the previous code consistently crashed with fd exhaustion. With `force_fpcalc=True` the import runs to completion.