From 2ed1c0c87166217009f8853f8e50930e0330f0e7 Mon Sep 17 00:00:00 2001 From: christos <christos@cern.ch> Date: Thu, 5 Aug 2021 21:53:01 +0200 Subject: [PATCH 1/2] Fix PyEval_InitThreads() and PyEval_ThreadsInitialized() deprecated warnings . Part II --- HLT/Trigger/TrigControl/TrigPSC/src/Psc.cxx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/HLT/Trigger/TrigControl/TrigPSC/src/Psc.cxx b/HLT/Trigger/TrigControl/TrigPSC/src/Psc.cxx index e0d42c867ee2..ac1527729c93 100644 --- a/HLT/Trigger/TrigControl/TrigPSC/src/Psc.cxx +++ b/HLT/Trigger/TrigControl/TrigPSC/src/Psc.cxx @@ -175,7 +175,10 @@ bool psc::Psc::configure(const ptree& config) ERS_DEBUG(1,"Initializing Python interpreter"); Py_Initialize(); - if (!PyEval_ThreadsInitialized()) PyEval_InitThreads(); + + /* + * The GIL is initialized by Py_Initialize() since Python 3.7." + */ // check if ( ! Py_IsInitialized() ) { @@ -676,10 +679,12 @@ bool psc::Psc::prepareWorker (const boost::property_tree::ptree& args) /* Release the Python GIL (which we inherited from the mother) to avoid dead-locking on the first call to Python. Only relevant if Python is initialized and Python-based algorithms are used. */ - if (PyEval_ThreadsInitialized()) { + + /* + * The GIL is initialized by Py_Initialize() since Python 3.7." + */ ERS_DEBUG(1, "Releasing Python GIL"); PyEval_SaveThread(); - } } m_workerID = args.get<int>("workerId"); -- GitLab From 59ed72a3f3fd296befca58910b193a41a8023c3d Mon Sep 17 00:00:00 2001 From: christos <christos@cern.ch> Date: Fri, 6 Aug 2021 18:43:03 +0200 Subject: [PATCH 2/2] Rafal comments --- HLT/Trigger/TrigControl/TrigPSC/src/Psc.cxx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/HLT/Trigger/TrigControl/TrigPSC/src/Psc.cxx b/HLT/Trigger/TrigControl/TrigPSC/src/Psc.cxx index ac1527729c93..53b8f819505b 100644 --- a/HLT/Trigger/TrigControl/TrigPSC/src/Psc.cxx +++ b/HLT/Trigger/TrigControl/TrigPSC/src/Psc.cxx @@ -679,12 +679,8 @@ bool psc::Psc::prepareWorker (const boost::property_tree::ptree& args) /* Release the Python GIL (which we inherited from the mother) to avoid dead-locking on the first call to Python. Only relevant if Python is initialized and Python-based algorithms are used. */ - - /* - * The GIL is initialized by Py_Initialize() since Python 3.7." - */ - ERS_DEBUG(1, "Releasing Python GIL"); - PyEval_SaveThread(); + ERS_DEBUG(1, "Releasing Python GIL"); + PyEval_SaveThread(); } m_workerID = args.get<int>("workerId"); -- GitLab