Skip to content

Commit f84239f

Browse files
Use py::gil_scoped_acquire instead of PyGILState_Ensure.
1 parent 24d7839 commit f84239f

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

dpctl/apis/include/dpctl4pybind11.hpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,14 +1000,10 @@ sycl::event keep_args_alive(sycl::queue q,
10001000
shp_arr[i]->inc_ref();
10011001
}
10021002
cgh.host_task([=]() {
1003-
bool guard = (Py_IsInitialized() && !_Py_IsFinalizing());
1004-
if (guard) {
1005-
PyGILState_STATE gstate;
1006-
gstate = PyGILState_Ensure();
1007-
for (std::size_t i = 0; i < num; ++i) {
1008-
shp_arr[i]->dec_ref();
1009-
}
1010-
PyGILState_Release(gstate);
1003+
py::gil_scoped_acquire acquire;
1004+
1005+
for (std::size_t i = 0; i < num; ++i) {
1006+
shp_arr[i]->dec_ref();
10111007
}
10121008
});
10131009
});

0 commit comments

Comments
 (0)