diff --git a/jupyterlab_h5web/handlers.py b/jupyterlab_h5web/handlers.py index 1f6fdec..884ec23 100644 --- a/jupyterlab_h5web/handlers.py +++ b/jupyterlab_h5web/handlers.py @@ -1,3 +1,4 @@ +import h5py from tornado.web import authenticated, MissingArgumentError from jupyter_server.base.handlers import APIHandler from jupyter_server.utils import url_path_join @@ -15,6 +16,12 @@ from .utils import as_absolute_path, create_error +H5PY_HAS_FILE_LOCKING_ARG = h5py.version.hdf5_version_tuple >= (1, 12, 1) or ( + h5py.version.hdf5_version_tuple[:2] == (1, 10) + and h5py.version.hdf5_version_tuple[2] >= 7 +) + + class BaseHandler(APIHandler): def initialize(self, base_dir: Path) -> None: self.base_dir = base_dir @@ -33,7 +40,7 @@ def get(self): as_absolute_path(self.base_dir, Path(file_path)), path, create_error, - h5py_options={"locking": False}, + h5py_options={"locking": False} if H5PY_HAS_FILE_LOCKING_ARG else {}, ) as content: payload = self.parse_content(content)