Skip to content

Commit 6719aba

Browse files
committed
fix: standard mutex for 3.13t
Signed-off-by: Henry Schreiner <[email protected]>
1 parent f0e6ac2 commit 6719aba

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/test_embed/test_interpreter.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -627,15 +627,23 @@ TEST_CASE("Threads") {
627627

628628
{
629629
py::gil_scoped_release gil_release{};
630+
#if defined(Py_GIL_DISABLED) && PY_VERSION_HEX < 0x03E0000
631+
std::mutex mutex;
632+
#endif
630633

631634
auto threads = std::vector<std::thread>();
632635
for (auto i = 0; i < num_threads; ++i) {
633636
threads.emplace_back([&]() {
634637
py::gil_scoped_acquire gil{};
635638
#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
636643
Py_BEGIN_CRITICAL_SECTION(locals.ptr());
637644
locals["count"] = locals["count"].cast<int>() + 1;
638645
Py_END_CRITICAL_SECTION();
646+
# endif
639647
#else
640648
locals["count"] = locals["count"].cast<int>() + 1;
641649
#endif

0 commit comments

Comments
 (0)