From fc492f31f7872e96dc4815bbce882767882986eb Mon Sep 17 00:00:00 2001 From: qbisi Date: Mon, 15 Sep 2025 15:56:52 +0800 Subject: [PATCH] Initailize python interpreter before getting GIL --- libsrc/core/python_ngcore.hpp | 1 + ng/ngappinit.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/libsrc/core/python_ngcore.hpp b/libsrc/core/python_ngcore.hpp index 2ce844817..4fc8aa4e1 100644 --- a/libsrc/core/python_ngcore.hpp +++ b/libsrc/core/python_ngcore.hpp @@ -2,6 +2,7 @@ #define NETGEN_CORE_PYTHON_NGCORE_HPP #include "ngcore_api.hpp" // for operator new +#include #include #include #include diff --git a/ng/ngappinit.cpp b/ng/ngappinit.cpp index f6b4be0a9..e21937b58 100644 --- a/ng/ngappinit.cpp +++ b/ng/ngappinit.cpp @@ -256,6 +256,7 @@ int main(int argc, char ** argv) Tk_MainLoop(); Tcl_DeleteInterp (myinterp); #ifdef NETGEN_PYTHON + py::scoped_interpreter guard{}; py::gil_scoped_acquire ensure_gil; #endif