Skip to content

Commit ab4d418

Browse files
committed
Call PyUnstable_Module_SetGIL for main and test extensions for no-GIL interpreters
1 parent da683e5 commit ab4d418

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/greenlet/greenlet.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ greenlet_internal_mod_init() noexcept
213213
try {
214214
CreatedModule m(greenlet_module_def);
215215

216+
#ifdef Py_GIL_DISABLED
217+
PyUnstable_Module_SetGIL(m.borrow(), Py_MOD_GIL_NOT_USED);
218+
#endif
219+
216220
Require(PyType_Ready(&PyGreenlet_Type));
217221
Require(PyType_Ready(&PyGreenletUnswitchable_Type));
218222

src/greenlet/tests/_test_extension_cpp.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ PyInit__test_extension_cpp(void)
221221
p_test_exception_throw_nonstd = test_exception_throw_nonstd;
222222
p_test_exception_throw_std = test_exception_throw_std;
223223
p_test_exception_switch_recurse = test_exception_switch_recurse;
224+
#ifdef Py_GIL_DISABLED
225+
PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED);
226+
#endif
227+
224228
#ifdef Py_GIL_DISABLED
225229
PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED);
226230
#endif

0 commit comments

Comments
 (0)