beets leaks file descriptors
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 2.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 31
Description
### Problem
I'm running `beet import` with the chroma plugin enabled. After some time beets cannot open any more files. I think what happens is that beet runs out of the maximum allowed file descriptors.
When I run `lsof | grep python` I can see that there are over 600 open sockets.
The problem goes away when I disable the chroma plugin.
The problem seems to occur because the fingerprinting via library fails on some files. While the fingerprinting eventually succeeds as chroma tries the next backend (fpcalc) the socket from the first attemt seems to stay open.
I patched beets locally to pass `force_fpcalc` to https://github.com/beetbox/pyacoustid. This also causes the problem to dissapear.
### Setup
* OS: Alpine Linux 3.19
* Python version: Python 3.11.8
* beets version: 1.6.0
* Turning off plugins made problem go away (yes/no): yes
My configuration (output of `beet config`) is:
```yaml
directory: /serra-storage/Music
library: /serra-storage/.Musiclibrary.db
plugins: chroma
import:
move: no
copy: no
per_disc_numbering: yes
chroma:
auto: yes
acoustid:
apikey: REDACTED
```
Contributor guide
Research direction
Start with the chroma plugin's fingerprinting path used by `beet import`, focusing on its pyacoustid backend fallback between the library backend and fpcalc. Reproduce the issue with the supplied configuration and monitor Python sockets with `lsof`; done means failed fingerprint attempts no longer accumulate open file descriptors and the import remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100