Skip to content

Commit 918fb72

Browse files
committed
feat: add py::mod_gil_used()
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 9aa3ab4 commit 918fb72

File tree

5 files changed

+6
-4
lines changed

5 files changed

+6
-4
lines changed

include/pybind11/pybind11.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,8 @@ class mod_gil_not_used {
12701270
bool flag_;
12711271
};
12721272

1273+
inline mod_gil_not_used mod_gil_used() { return mod_gil_not_used(false); }
1274+
12731275
class multiple_interpreters {
12741276
public:
12751277
enum class level {

tests/exo_planet_pybind11.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace pybind11_tests {
1111
namespace test_cpp_conduit {
1212

13-
PYBIND11_MODULE(exo_planet_pybind11, m, ) {
13+
PYBIND11_MODULE(exo_planet_pybind11, m, pybind11::mod_gil_used()) {
1414
wrap_traveler(m);
1515
m.def("wrap_very_lonely_traveler", [m]() { wrap_very_lonely_traveler(m); });
1616
}

tests/extra_setuptools/test_setuphelper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_simple_setup_py(monkeypatch, tmpdir, parallel, std):
6565
int f(int x) {
6666
return x * 3;
6767
}
68-
PYBIND11_MODULE(simple_setup, m) {
68+
PYBIND11_MODULE(simple_setup, m, pybind11::mod_gil_used()) {
6969
m.def("f", &f);
7070
}
7171
"""

tests/home_planet_very_lonely_traveler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace pybind11_tests {
66
namespace test_cpp_conduit {
77

8-
PYBIND11_MODULE(home_planet_very_lonely_traveler, m, ) {
8+
PYBIND11_MODULE(home_planet_very_lonely_traveler, m, py::mod_gil_used()) {
99
m.def("wrap_very_lonely_traveler", [m]() { wrap_very_lonely_traveler(m); });
1010
}
1111

tests/test_cross_module_rtti/bindings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class BaseTrampoline : public lib::Base, public pybind11::trampoline_self_life_s
88
int get() const override { PYBIND11_OVERLOAD(int, lib::Base, get, ); }
99
};
1010

11-
PYBIND11_MODULE(test_cross_module_rtti_bindings, m, ) {
11+
PYBIND11_MODULE(test_cross_module_rtti_bindings, m, pybind11::mod_gil_used()) {
1212
pybind11::classh<lib::Base, BaseTrampoline>(m, "Base")
1313
.def(pybind11::init<int, int>())
1414
.def_readwrite("a", &lib::Base::a)

0 commit comments

Comments
 (0)