Skip to content

Commit aa1c3aa

Browse files
committed
Disable thread local cache for internals_pp_manager for multi-interpreter only
1 parent 4ef8b0c commit aa1c3aa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

include/pybind11/detail/internals.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,16 @@ class internals_pp_manager {
648648
/// Get the current pointer-to-pointer, allocating it if it does not already exist. May
649649
/// acquire the GIL. Will never return nullptr.
650650
std::unique_ptr<InternalsType> *get_pp() {
651+
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
651652
gil_scoped_acquire_simple gil;
652653
return get_or_create_pp_in_state_dict();
654+
#else
655+
if (!internals_singleton_pp_) {
656+
gil_scoped_acquire_simple gil;
657+
internals_singleton_pp_ = get_or_create_pp_in_state_dict();
658+
}
659+
return internals_singleton_pp_;
660+
#endif
653661
}
654662

655663
/// Drop all the references we're currently holding.

0 commit comments

Comments
 (0)