File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -602,6 +602,15 @@ class internals_pp_manager {
602602 // / acquire the GIL. Will never return nullptr.
603603 std::unique_ptr<InternalsType> *get_pp () {
604604#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
605+ // WARNING: We cannot use `get_num_interpreters_seen() > 1` here to create a fast path for
606+ // the single-interpreter case.
607+ // For multi-interpreter support, the subinterpreters can be initialized concurrently, such
608+ // as using `InterpreterPoolExecutor` in Python. The first time this function may not be
609+ // called in the main interpreter, e.g., a clean main interpreter that does not import any
610+ // pybind11 module. Multiple subinterpreters may observe `get_num_interpreters_seen() <= 1`
611+ // at the same time, while `get_num_interpreters_seen() += 1` in `PYBIND11_MODULE(...)` is
612+ // called later.
613+
605614 // Whenever the interpreter changes on the current thread we need to invalidate the
606615 // internals_pp so that it can be pulled from the interpreter's state dict. That is
607616 // slow, so we use the current PyThreadState to check if it is necessary.
You can’t perform that action at this time.
0 commit comments