chroma: use force_fpcalc=True to prevent fd exhaustion - #6928
Open
slmingol wants to merge 5 commits into
Open
Conversation
audioread's GStreamer backend leaks file descriptors when fingerprinting fails or errors occur. 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. Fixes beetbox#5171 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6928 +/- ##
==========================================
+ Coverage 75.78% 75.84% +0.05%
==========================================
Files 164 164
Lines 21437 21437
Branches 3379 3379
==========================================
+ Hits 16247 16259 +12
+ Misses 4387 4374 -13
- Partials 803 804 +1
🚀 New features to boost your workflow:
|
Dockerfile patches chroma.py in the linuxserver/beets base image to use force_fpcalc=True, fixing fd exhaustion on large libraries (beetbox#5171). GHA workflow builds and pushes to ghcr.io/slmingol/beets on every push to master and weekly to pick up upstream linuxserver base updates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Multi-line format for fingerprint_file calls (ruff E501) - Catch TypeError for pyacoustid versions < 1.2.0 without force_fpcalc - Add changelog entry for beetbox#5171 fix Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers the two code paths added in the beetbox#5171 fix: - force_fpcalc=True is passed to acoustid.fingerprint_file - TypeError from old pyacoustid (<1.2.0) is caught and logged, not raised Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.