[Yt-dev] h5py bug

Matthew Turk matthewturk at gmail.com
Tue Apr 12 14:12:40 PDT 2011


Hi Stephen and everyone else,

Stephen's right, this is a bug; I rescind my earlier conservatism and
hereby eat crow.  He did the work of looking for API changes, of which
it seems there are none, so I have updated the install script to h5py
1.3.1.  I still think we need to account for people using 1.2.0, which
means being more careful about our variable names.

-Matt

On Mon, Apr 11, 2011 at 10:32 PM, Matthew Turk <matthewturk at gmail.com> wrote:
> Hi Stephen,
>
> Yes, this errors out for me.
>
> What it looks like is that the deallocation routine is being deferred.
>  HDF5 keeps a global state of files, and the order in which the
> variable is dereferences, the file objects are closed, and the new
> file is assigned is conflicting.  In short, what I *think* is going
> on, but which I may be wrong about:
>
> h5py.File("whatever") is being evaluated.
> Subsequently, it is assigned to variable 'f'
> Then, as a result of this, the *old* variable 'f''s reference count
> drops to zero.  This calls the deallocation routine.
> However, at this point, the file has been re-opened by a different variable.
>
> This is all fixed if you use a different variable name for the second opening:
>
> import h5py
> f = h5py.File('test.h5')
> f.close()
> f2 = h5py.File('test.h5')
> print f2['Grid00000001']['particle_position_x'][:]
> f2.close()
>
> If the variable goes out of scope, the same thing should work.
> Additionally, the second 'del f' on line 881 of halo_objects should
> not be necessary for this fix.  Can you see if it is?
>
> Perhaps more descriptive variable names (something I too am guilty of,
> all too often) would obviate the need for all the del's.
>
> -Matt
>
> On Mon, Apr 11, 2011 at 10:22 PM, Stephen Skory <s at skory.us> wrote:
>> Hi all,
>>
>>> I'll report it upstream if I can replicate it in a simple script. I'll
>>> also give 1.2.1 a shot, which is also available. I'll let you know.
>>
>> After some testing, 1.2.1 does not fix the error. I've also found that
>> a simple script like this will make the error:
>>
>> import h5py
>> f = h5py.File('data0090.cpu0000')
>> f.close()
>> f = h5py.File('data0090.cpu0000')
>> print f['Grid00000001']['particle_position_x'][:]
>> f.close()
>>
>> Can someone try this on some data to see if they get the error too? Thanks!
>>
>>
>> --
>> Stephen Skory
>> s at skory.us
>> http://stephenskory.com/
>> 510.621.3687 (google voice)
>> _______________________________________________
>> Yt-dev mailing list
>> Yt-dev at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
>>
>



More information about the yt-dev mailing list