Skip to content

Close open temporary file descriptor when reading par file from HDF5 HeterodynedData object

Matthew Pitkin requested to merge open_files_issue into master

In !191 (merged) I tried to solve the issue of too many files being open when generating the summary pages, but apparently it didn't solve the problem. I think I might have tracked down the issue. When reading in a HeterodynedData object from a HDF5 file, the par file information is stored in a string, but to get it back into the new HeterodynedData object I need to temporarily store it in a file. To do this I used mkstemp to create a temporary file. But, I was ignoring the first value that returns, which is a file descriptor pointing to the open file. I was subsequently re-opening and close the file, but not closing that original file descriptor. I think this might have left an open file hanging about for each HeteodynedData object read in.

This MR fixes this, bu actually returning the file descriptor and manually closing it.

Merge request reports