Skip to content

Commit 22968e9

Browse files
committed
Have to join these threads to make sure they are totally done before the test returns.
1 parent 3036f9f commit 22968e9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/test_embed/test_interpreter.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ TEST_CASE("Per-Subinterpreter GIL") {
548548
main_tstate); // switch back so the scoped_acquire can release the GIL properly
549549
};
550550

551-
std::thread(thread_main, 1).detach();
552-
std::thread(thread_main, 2).detach();
551+
std::thread t1(thread_main, 1);
552+
std::thread t2(thread_main, 2);
553553

554554
// we spawned two threads, at this point they are both waiting for started to increase
555555
++started;
@@ -590,6 +590,9 @@ TEST_CASE("Per-Subinterpreter GIL") {
590590
std::this_thread::sleep_for(std::chrono::microseconds(1));
591591
}
592592

593+
t1.join();
594+
t2.join();
595+
593596
// now we have the gil again, sanity check
594597
REQUIRE(py::cast<std::string>(py::module_::import("external_module").attr("multi_interp"))
595598
== "1");

0 commit comments

Comments
 (0)