Skip to content

Commit

Permalink
Check libhdf5 version for support of the locking argument
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed May 15, 2023
1 parent 5823d42 commit 2be7010
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion jupyterlab_h5web/handlers.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit 2be7010

Please sign in to comment.