Skip to content

Commit

Permalink
Merge pull request #372 from nominee1997/improve-multithreading
Browse files Browse the repository at this point in the history
Improve support for multithreading
  • Loading branch information
xhochy authored May 9, 2023
2 parents dcc4c05 + 5eb3ea4 commit 820675d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace turbodbc { namespace bindings {

void for_connect(pybind11::module & module)
{
module.def("connect", turbodbc::connect);
module.def("connect", turbodbc::connect, pybind11::call_guard<pybind11::gil_scoped_release>());
}

} }
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ namespace turbodbc { namespace bindings {

void for_connection(pybind11::module &module) {
pybind11::class_<turbodbc::connection>(module, "Connection")
.def("commit", &turbodbc::connection::commit)
.def("rollback", &turbodbc::connection::rollback)
.def("cursor", &turbodbc::connection::make_cursor)
.def("set_autocommit", &turbodbc::connection::set_autocommit)
.def("commit", &turbodbc::connection::commit, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("rollback", &turbodbc::connection::rollback, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("cursor", &turbodbc::connection::make_cursor, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("set_autocommit", &turbodbc::connection::set_autocommit, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("autocommit_enabled", &turbodbc::connection::autocommit_enabled)
;

Expand Down
9 changes: 3 additions & 6 deletions cpp/turbodbc_python/Library/src/python_bindings/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ namespace turbodbc { namespace bindings {
void for_cursor(pybind11::module & module)
{
pybind11::class_<turbodbc::cursor>(module, "Cursor")
.def("prepare", &turbodbc::cursor::prepare)
.def("execute", [](turbodbc::cursor& cursor) {
pybind11::gil_scoped_release release;
cursor.execute();
})
.def("_reset", &turbodbc::cursor::reset)
.def("prepare", &turbodbc::cursor::prepare, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("execute", &turbodbc::cursor::execute, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("_reset", &turbodbc::cursor::reset, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("get_row_count", &turbodbc::cursor::get_row_count)
.def("get_result_set", &turbodbc::cursor::get_result_set)
.def("more_results", &turbodbc::cursor::more_results)
Expand Down

0 comments on commit 820675d

Please # to comment.