Salome HOME
[EDF29150] : Make the trace messages clearer and more efficient.
[modules/kernel.git] / src / ParallelContainer / SALOME_ParallelContainerProxy_i.cxx
index e2f8d4170b89704b6af91266826f87f798e19bde..f2cd9e701f6caf80cfcf64d59c8de90e157e391a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -57,10 +57,11 @@ Container_proxy_impl_final::Container_proxy_impl_final(CORBA::ORB_ptr orb,
   myCommand += _containerName + "','";
   myCommand += sior;
   myCommand += "')\n";
-  Py_ACQUIRE_NEW_THREAD;
-  PyRun_SimpleString("import SALOME_Container\n");
-  PyRun_SimpleString((char*)myCommand.c_str());
-  Py_RELEASE_NEW_THREAD;
+  {
+    AutoGIL agil;
+    PyRun_SimpleString("import SALOME_Container\n");
+    PyRun_SimpleString((char*)myCommand.c_str());
+  }
 }
 
 Container_proxy_impl_final:: ~Container_proxy_impl_final() {
@@ -69,7 +70,7 @@ Container_proxy_impl_final:: ~Container_proxy_impl_final() {
   if (_NS)
     delete _NS;
 
-  // _fab_thread not deleted beacause fab_thread is managed
+  // _fab_thread not deleted because fab_thread is managed
   // by paco_fabrique_manager
 }
 
@@ -209,16 +210,17 @@ Container_proxy_impl_final::load_component_Library(const char* componentName, CO
 #endif
 
       MESSAGE("Try to import Python component "<<componentName);
-      Py_ACQUIRE_NEW_THREAD;
-      PyObject *mainmod = PyImport_AddModule("__main__");
-      PyObject *globals = PyModule_GetDict(mainmod);
-      PyObject *pyCont = PyDict_GetItemString(globals, "pyCont");
-      PyObject *result = PyObject_CallMethod(pyCont,
-                                             (char*)"import_component",
-                                             (char*)"s",componentName);
-      std::string ret_p= PyUnicode_AsUTF8(result);
-      Py_XDECREF(result);
-      Py_RELEASE_NEW_THREAD;
+      {
+        AutoGIL agil;
+        PyObject *mainmod = PyImport_AddModule("__main__");
+        PyObject *globals = PyModule_GetDict(mainmod);
+        PyObject *pyCont = PyDict_GetItemString(globals, "pyCont");
+        PyObject *result = PyObject_CallMethod(pyCont,
+                                              (char*)"import_component",
+                                              (char*)"s",componentName);
+        std::string ret_p= PyUnicode_AsUTF8(result);
+        Py_XDECREF(result);
+      }
 
       if (ret_p=="") // import possible: Python component
       {
@@ -350,7 +352,7 @@ Container_proxy_impl_final::create_component_instance_env(const char* componentN
     string instanceName = aCompName + "_inst_" + aNumI ;
     string component_registerName = _containerName + "/" + instanceName;
 
-    // --- Instanciate required CORBA object
+    // --- Instantiate required CORBA object
     Container_proxy_impl_final::proxy_object * proxy = new Container_proxy_impl_final::proxy_object();
     
     proxy->proxy_id = (component_proxy_factory) (_orb, 
@@ -386,7 +388,7 @@ Container_proxy_impl_final::create_component_instance_env(const char* componentN
   }
   catch (...)
   {
-    INFOS( "Exception catched in Proxy creation" );
+    INFOS( "Exception caught in Proxy creation" );
     return Engines::EngineComponent::_nil();
   }