beetbox / beetbox/audioread

stream not properly closed (NoBackendError | OSError: Too many open files)

Open
#134 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
538
Forks
112
PR merge metrics
No merged PRs in 30d

Description

```
import audioread

filename = 'some_audio_file.ogg'
try:
for K in range(2048):
with audioread.audio_open(filename) as audio:
print(K, audio.duration)
except audioread.exceptions.NoBackendError:
with open(filename, 'rb') as file: # OSError: [Errno 24] Too many open files
pass
```
the audio is openned in a loop using with, but it seems that is not properly closed
in my system it will print about 500 lines, then raises the NoBackendError and the OSError when trying to open a new file

using `lsof` shows lines of the form (my limit is 1024)
```
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python 38124 ne555 1023u unix 0x00000000d813f451 0t0 2420780 type=STREAM (CONNECTED)
```

I've observed this issue with audioread.gstdec.GstAudioFile and audioread.ffdec.FFmpegAudioFile backends, couldn't test with audioread.rawread.RawAudioFile

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the repeated audioread.audio_open() example and inspect the GstAudioFile and FFmpegAudioFile backends named in the report, comparing their resource cleanup with RawAudioFile. Reproduce the loop while monitoring open descriptors with lsof; done means repeated opens and closes do not exhaust file descriptors and the reported exceptions no longer occur.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.