From 5d491c51abf5575af47ed7154303731a78125c4c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 11:14:56 -0500 Subject: [PATCH] [python] Release GIL in VFS bindings (#3553) (#3564) Co-authored-by: nguyenv --- apis/python/src/tiledbsoma/soma_vfs.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apis/python/src/tiledbsoma/soma_vfs.cc b/apis/python/src/tiledbsoma/soma_vfs.cc index c565684e92..cc0211df72 100644 --- a/apis/python/src/tiledbsoma/soma_vfs.cc +++ b/apis/python/src/tiledbsoma/soma_vfs.cc @@ -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); } @@ -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()) .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()) .def("close", &SOMAVFSFilebuf::close, "should_throw"_a = true); } } // namespace libtiledbsomacpp \ No newline at end of file