fix: shim python create thread to audit threads (#16682)

* fix: shim python create thread to audit threads

* fix: Python thread audit shim kwargs forwarding
This commit is contained in:
Ian Chua authored and GitHub committed 2026-10-22 13:39:48 +08:00
1 parent 6b51185fd6
commit 59e96b71d0
3 files changed
+102

No files matched your search

+6
View File
@@ -2,6 +2,7 @@
#include "GeneratedConfig.hpp"
#include "libslic3r/Utils.hpp"
#include "PluginAuditManager.hpp"
#include "PythonPluginBridge.hpp"
#include <atomic>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
@@ -664,6 +665,11 @@ bool PythonInterpreter::initialize()
// background-thread exceptions) to <data_dir>/log/python_*.log.
install_python_stderr_redirect();
// Attribute plugin-spawned Python threads to the plugin/capability that created them.
// Must run while the GIL is still held here, after the audit hook is in place and
// before the GIL is released below.
install_python_thread_audit_shim();
// Release the GIL so other threads can acquire it via PyGILState_Ensure.
// Without this, calls from background threads will block trying to acquire the GIL.
m_main_thread_state = PyEval_SaveThread();