HDFGroup / h5pyd

h5py distributed - Python client library for HDF Rest API
Other
111 stars 39 forks source link

Determining open status of remote file #23

Closed rayosborn closed 7 years ago

rayosborn commented 7 years ago

In h5py, I use the file id to determine if a file is open or not. So defining this function:

def isopen(f):
    if f:
        print('File is open')
    else:
        print('File is closed')

I get the following with a local HDF5 file.

>>> a=h5.File('chopper.nxs')
>>> isopen(a)
File is open
>>> a.close()
>>> isopen(a)
File is closed

With h5pyd, I get the following:

>>> a=h5d.File('chopper.exfac', mode='r', endpoint='http://some.server:5000')
>>> isopen(a)
File is open
>>> a.close()
>>> isopen(a)
File is open

I can use the File id.uuid property instead, since that is set to 0 when the file is closed, but the current behavior is not fully compatible with h5py.

jreadey commented 7 years ago

This should be fixed with commit: https://github.com/HDFGroup/h5pyd/commit/895e8729612a1fa8817d0984dc3239ca2d3296a6.