We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f0e6ac2 commit 6719abaCopy full SHA for 6719aba
tests/test_embed/test_interpreter.cpp
@@ -627,15 +627,23 @@ TEST_CASE("Threads") {
627
628
{
629
py::gil_scoped_release gil_release{};
630
+#if defined(Py_GIL_DISABLED) && PY_VERSION_HEX < 0x03E0000
631
+ std::mutex mutex;
632
+#endif
633
634
auto threads = std::vector<std::thread>();
635
for (auto i = 0; i < num_threads; ++i) {
636
threads.emplace_back([&]() {
637
py::gil_scoped_acquire gil{};
638
#ifdef Py_GIL_DISABLED
639
+# if PY_VERSION_HEX < 0x03E0000
640
+ std::lock_guard<std::mutex> lock(mutex);
641
+ locals["count"] = locals["count"].cast<int>() + 1;
642
+# else
643
Py_BEGIN_CRITICAL_SECTION(locals.ptr());
644
locals["count"] = locals["count"].cast<int>() + 1;
645
Py_END_CRITICAL_SECTION();
646
+# endif
647
#else
648
649
#endif
0 commit comments