Skip to content

Commit

Permalink
[python] Release GIL in VFS bindings (#3553) (#3564)
Browse files Browse the repository at this point in the history
Co-authored-by: nguyenv <[email protected]>
  • Loading branch information
github-actions[bot] and nguyenv authored Jan 15, 2025
1 parent 7f0ac88 commit 5d491c5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions apis/python/src/tiledbsoma/soma_vfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ class SOMAVFSFilebuf : public tiledb::impl::VFSFilebuf {
return py::bytes("");
}

py::gil_scoped_release release;
std::string buffer(nbytes, '\0');
offset_ += xsgetn(&buffer[0], nbytes);
py::gil_scoped_acquire acquire;

return py::bytes(buffer);
}

Expand All @@ -104,10 +107,16 @@ void load_soma_vfs(py::module& m) {
"open",
[](SOMAVFSFilebuf& buf, const std::string& uri) {
return buf.open(uri, std::ios::in);
})
},
py::call_guard<py::gil_scoped_release>())
.def("read", &SOMAVFSFilebuf::read, "size"_a = -1)
.def("tell", &SOMAVFSFilebuf::tell)
.def("seek", &SOMAVFSFilebuf::seek, "offset"_a, "whence"_a = 0)
.def(
"seek",
&SOMAVFSFilebuf::seek,
"offset"_a,
"whence"_a = 0,
py::call_guard<py::gil_scoped_release>())
.def("close", &SOMAVFSFilebuf::close, "should_throw"_a = true);
}
} // namespace libtiledbsomacpp

0 comments on commit 5d491c5

Please sign in to comment.