Leaked file descriptor in Deer observables class
kain88-de opened this issue · comments
BioEn/bioen/analyze/observables/deer/deer.py
Lines 42 to 43 in 1927780
This line contains a leak. The call to open
returns a file descriptor that is never closed again. This is OK when using only the bioen
CLI tool. It will be a problem when using the library from python and analyzing a lot of deer data examples with pkl_out
set because each process only is allowed a limited number of open file descriptors. The correct solution would be to use a context manager.
Thanks, the code was improved by introducting a context manager (though CPython should close the file handle automatically, latest when the instance of the Deer class is destructed).
though CPython should close the file handle automatically, latest when the instance of the Deer class is destructed
I thought so too. But some time ago I fixed similar code in the python-mmtf package that showed a lot of leaked file descriptors in tests of MDAnalysis.