]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Fix KERNEL_LC_LifeCycleCORBA_SWIGTest KERNEL_LifeCycleCORBA KERNEL_UnitTests tests... mkarpuni/32519_parametrize_commands_in_kernel
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 4 Apr 2023 08:20:48 +0000 (10:20 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 4 Apr 2023 08:20:48 +0000 (10:20 +0200)
src/Container/SALOME_CPythonHelper.cxx
src/Container/SALOME_CPythonHelper.hxx
src/Launcher/SALOME_LauncherServer.cxx

index 07631c7db03beaaf9a08b7b1c4c0c040b0a6d0a4..ee06f9568b03813c28d1218c2415164737b309d9 100644 (file)
@@ -77,6 +77,14 @@ void SALOME_CPythonHelper::initializePython(int argc, char *argv[])
   PyDict_SetItemString(_globals,"socket",socket);
 }
 
+void SALOME_CPythonHelper::allowPythonCallsFromDifferentThread() const
+{
+#if PY_VERSION_HEX < 0x03070000
+  PyEval_InitThreads(); /* Create (and acquire) the interpreter lock (for threads)*/
+#endif
+  PyEval_SaveThread(); /* Release the thread state */
+}
+
 void SALOME_CPythonHelper::registerToSalomePiDict(const std::string& processName, long pid) const
 {
   AutoGIL agil;
index b93e400b43d0928efc4ce518de9767702063d824..e7372d16bfdbe06face4af1126cf6f185857dd21 100644 (file)
@@ -31,6 +31,7 @@ class CONTAINER_EXPORT SALOME_CPythonHelper
 {
  public:
   void initializePython(int argc, char *argv[]);
+  void allowPythonCallsFromDifferentThread() const;
   void registerToSalomePiDict(const std::string& processName, long pid) const;
   std::vector<long> evalVL(const std::string& pyCode) const;
   std::string evalS(const std::string& pyCode) const;
index ed41de8b5246a2d4ba566b471332b181d96ae2f7..8ceb76486c5b4865a6a9f5632b0f4b90ad9288cb 100644 (file)
@@ -118,6 +118,7 @@ int main(int argc, char* argv[])
       threadPol->destroy();
       SALOME_CPythonHelper cPyh;
       cPyh.initializePython(argc,argv);
+      cPyh.allowPythonCallsFromDifferentThread();
       SALOME_Launcher *lServ(new SALOME_Launcher(orb,safePOA));
       lServ->DeclareUsingSalomeSession();
       lServ->_remove_ref();