Skip to content

Commit 6922d7d

Browse files
committed
Add lock under multiple interpreters
1 parent 2c83462 commit 6922d7d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

include/pybind11/detail/internals.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,11 @@ class internals_pp_manager {
712712
}
713713

714714
static void fail_if_internals_recreated(std::unique_ptr<InternalsType> *pp) {
715+
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
716+
static std::mutex mtx;
717+
std::lock_guard<std::mutex> lock(mtx);
718+
#endif
719+
715720
auto &pps_have_created_content_ = pps_have_created_content();
716721

717722
// Prevent re-creation of internals after destruction during interpreter shutdown.

0 commit comments

Comments
 (0)