-
Notifications
You must be signed in to change notification settings - Fork 476
Description
I ran into a problem when loading a bunch of directivities from Sofa files using MeasuredDirectivityFile(). Sometimes the script would crash silently without any error message.
The problem seems to stem from open_sofa_file (directivities/sofa.py). The handle opened with file_sofa = sofa.Database.open(path) is not closed. I guess in some circumstances it leads to a crash. The problem was fixed for me when I added file_sofa.close() to the last line of open_sofa_file() before the return statement.
Unfortunately I wasn't able to come up with a minimal example to reliably produce the crash. However, it seems to solve the problem for me and I think it's a safe modification to do in any case, so maybe it's worth adding to the source code?
Thanks for the superb library - I use it all the time!
Python version: 3.11.8
Pyroomacoustics version: 0.8.4
Venv dependencies: pyroomacoustics, numpy, python-sofa