[Lldb-commits] [lldb] [lldb] Eliminate InitializePythonRAII::InitializeThreadsPrivate (NFC) (PR #151780)
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Fri Aug 1 16:22:00 PDT 2025
================
@@ -137,7 +137,16 @@ struct InitializePythonRAII {
config.install_signal_handlers = 0;
Py_InitializeFromConfig(&config);
PyConfig_Clear(&config);
- InitializeThreadsPrivate();
+
+ // The only case we should go further and acquire the GIL: it is unlocked.
+ if (PyGILState_Check())
+ return;
+
+ m_was_already_initialized = true;
+ m_gil_state = PyGILState_Ensure();
+ LLDB_LOGV(GetLog(LLDBLog::Script),
+ "Ensured PyGILState. Previous state = {0}locked\n",
+ m_gil_state == PyGILState_UNLOCKED ? "un" : "");
----------------
medismailben wrote:
nit: this is more readable.
```suggestion
"Ensured PyGILState. Previous state = {0}\n",
m_gil_state == PyGILState_UNLOCKED ? "unlocked" : "locked");
```
https://github.com/llvm/llvm-project/pull/151780
More information about the lldb-commits
mailing list