Skip to content

Commit 7cbc3fc

Browse files
committed
Fix this embedded GIL test for free-threading
1 parent 8160c8a commit 7cbc3fc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/test_embed/test_interpreter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,13 @@ TEST_CASE("Threads") {
637637
for (auto i = 0; i < num_threads; ++i) {
638638
threads.emplace_back([&]() {
639639
py::gil_scoped_acquire gil{};
640+
#ifdef Py_GIL_DISABLED
641+
Py_BEGIN_CRITICAL_SECTION(locals);
640642
locals["count"] = locals["count"].cast<int>() + 1;
643+
Py_END_CRITICAL_SECTION();
644+
#else
645+
locals["count"] = locals["count"].cast<int>() + 1;
646+
#endif
641647
});
642648
}
643649

0 commit comments

Comments
 (0)