Opening, closing, re-opening HDF5 files
Hi all, I've got a problem I'm trying to solve regarding HDF5, and I've found it's specifically related to yt. This sequence works: f = h5py.open(filename, "r") do stuff with f f.close() f = h5py.open(filename, "r+") However, this sequence does not: pf = load(filename) do stuff with the pf pf._handle.close() del pf f = h5py.open(filename, "r+") It results in this: --------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-8-186261e4952a> in <module>() ----> 1 f = h5py.File("desktop_stuff/GasSloshing/GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150", "r+") NameError: name 'h5py' is not defined In [9]: import h5py In [10]: f = h5py.File("desktop_stuff/GasSloshing/GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150", "r+") --------------------------------------------------------------------------- IOError Traceback (most recent call last) <ipython-input-10-186261e4952a> in <module>() ----> 1 f = h5py.File("desktop_stuff/GasSloshing/GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150", "r+") /Users/jzuhone/yt-x86_64/lib/python2.7/site-packages/h5py/_hl/files.pyc in __init__(self, name, mode, driver, libver, **kwds) 148 pass 149 fapl = make_fapl(driver,libver,**kwds) --> 150 fid = make_fid(name, mode, fapl) 151 Group.__init__(self, fid) 152 self._shared.lcpl = make_lcpl() /Users/jzuhone/yt-x86_64/lib/python2.7/site-packages/h5py/_hl/files.pyc in make_fid(name, mode, plist) 45 fid = h5f.open(name, h5f.ACC_RDONLY, fapl=plist) 46 elif mode == 'r+': ---> 47 fid = h5f.open(name, h5f.ACC_RDWR, fapl=plist) 48 elif mode == 'w-': 49 fid = h5f.create(name, h5f.ACC_EXCL, fapl=plist) /Users/jzuhone/yt-x86_64/lib/python2.7/site-packages/h5py/h5f.so in h5py.h5f.open (h5py/h5f.c:1618)() IOError: unable to open file (File accessability: Unable to open file) Anyone have any ideas? Best, John Z
Hi John,
I tracked this down. The GDF frontend's _is_valid routine was leaving
a dangling HDF5 handle open; this was showing up in the load() call.
I've issued a PR I'd like you to test. It also includes a check on
the _particle_handle during the finalizer for FLASHStaticOutput.
https://bitbucket.org/yt_analysis/yt/pull-request/368/fixing-hdf5-dangling-h...
-Matt
On Mon, Dec 10, 2012 at 7:27 PM, John ZuHone
Hi all,
I've got a problem I'm trying to solve regarding HDF5, and I've found it's specifically related to yt.
This sequence works:
f = h5py.open(filename, "r")
do stuff with f
f.close()
f = h5py.open(filename, "r+")
However, this sequence does not:
pf = load(filename)
do stuff with the pf
pf._handle.close()
del pf
f = h5py.open(filename, "r+")
It results in this:
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-8-186261e4952a> in <module>() ----> 1 f = h5py.File("desktop_stuff/GasSloshing/GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150", "r+")
NameError: name 'h5py' is not defined
In [9]: import h5py
In [10]: f = h5py.File("desktop_stuff/GasSloshing/GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150", "r+") --------------------------------------------------------------------------- IOError Traceback (most recent call last) <ipython-input-10-186261e4952a> in <module>() ----> 1 f = h5py.File("desktop_stuff/GasSloshing/GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150", "r+")
/Users/jzuhone/yt-x86_64/lib/python2.7/site-packages/h5py/_hl/files.pyc in __init__(self, name, mode, driver, libver, **kwds) 148 pass 149 fapl = make_fapl(driver,libver,**kwds) --> 150 fid = make_fid(name, mode, fapl) 151 Group.__init__(self, fid) 152 self._shared.lcpl = make_lcpl()
/Users/jzuhone/yt-x86_64/lib/python2.7/site-packages/h5py/_hl/files.pyc in make_fid(name, mode, plist) 45 fid = h5f.open(name, h5f.ACC_RDONLY, fapl=plist) 46 elif mode == 'r+': ---> 47 fid = h5f.open(name, h5f.ACC_RDWR, fapl=plist) 48 elif mode == 'w-': 49 fid = h5f.create(name, h5f.ACC_EXCL, fapl=plist)
/Users/jzuhone/yt-x86_64/lib/python2.7/site-packages/h5py/h5f.so in h5py.h5f.open (h5py/h5f.c:1618)()
IOError: unable to open file (File accessability: Unable to open file)
Anyone have any ideas?
Best,
John Z _______________________________________________ yt-dev mailing list yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
participants (2)
-
John ZuHone
-
Matthew Turk