How To Close An Hdf5 Using Low Level Python Api?
I was able to modify the cache settings of an HDF5 file by combining both the high and low level Python h5py API as defined in the following Stack Overflow question: How to set cac
Solution 1:
I think you are looking for .close()
f.close()
Although looking closer, I'm not sure why contextlib.closing(...) didn't work.
I edited the line involving contextlib to be:
with contextlib.closing(h5py.File(filename, fapl=propfaid)) as fid:
and removed
f = h5py.File(fid)
Afterwards, I could check that fid was closed and renaming file worked as expected.
print fid
<Closed HDF5 file>
os.rename(filename, 'foo2.hdf5')
No errors and check of directory shows the new name
Post a Comment for "How To Close An Hdf5 Using Low Level Python Api?"