Salome HOME
For future compatibility with python 3.9.
[modules/yacs.git] / src / runtime / RuntimeSALOME.cxx
index 5bcca56fc5ba21f0823ecacd1a54755bb838abeb..99f57715231a2a5b4b84e12db0a0226586217b13 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -314,7 +314,9 @@ void RuntimeSALOME::init(long flags, int argc, char* argv[])
               }
               PySys_SetArgv(pyArgc, changed_pyArgv);
             }
+#if PY_VERSION_HEX < 0x03070000
           PyEval_InitThreads(); /* Create (and acquire) the interpreter lock (for threads)*/
+#endif
           PyEval_SaveThread(); /* Release the thread state */
           //here we do not have the Global Interpreter Lock
         }
@@ -456,14 +458,14 @@ std::vector< std::pair<std::string,int> > RuntimeSALOME::getCatalogOfComputeNode
   }
   catch(SALOME_Exception& e)
   {
-    throw Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Unable to contact the SALOME Naming Service");
+    throw Exception("RuntimeSALOME::getCatalogOfComputeNodes : Unable to contact the SALOME Naming Service");
   }
   CORBA::Object_var obj(namingService.Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS));
   if(CORBA::is_nil(obj))
-    throw Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Unable to access to the resource manager !");
+    throw Exception("RuntimeSALOME::getCatalogOfComputeNodes : Unable to access to the resource manager !");
   Engines::ResourcesManager_var resManager(Engines::ResourcesManager::_narrow(obj));
   if(CORBA::is_nil(resManager))
-    throw Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Internal error ! The entry attached to the res manager in NS does not have right type !");
+    throw Exception("RuntimeSALOME::getCatalogOfComputeNodes : Internal error ! The entry attached to the res manager in NS does not have right type !");
   std::vector< std::pair<std::string,int> > ret;
   Engines::ResourceParameters params;
   params.name = "";
@@ -478,18 +480,27 @@ std::vector< std::pair<std::string,int> > RuntimeSALOME::getCatalogOfComputeNode
   params.can_launch_batch_jobs = false;
   params.can_run_containers = true;
   params.componentList.length(0);
-  Engines::ResourceList_var resourceList;
-  resourceList = resManager->GetFittingResources(params);
-  ret.reserve(resourceList->length());
-  for(int i = 0; i<resourceList->length(); i++)
+  try
+  {
+    Engines::ResourceList_var resourceList;
+    resourceList = resManager->GetFittingResources(params);
+    ret.reserve(resourceList->length());
+    for(int i = 0; i<resourceList->length(); i++)
+    {
+      const char* resource_name = resourceList[i];
+      std::string std_resource_name = resource_name;
+      Engines::ResourceDefinition_var resource_definition
+                              = resManager->GetResourceDefinition(resource_name);
+      int nb_cores = resource_definition->nb_node *
+                     resource_definition->nb_proc_per_node;
+      ret.push_back(std::pair<std::string,int>(resource_name, nb_cores));
+    }
+  }
+  catch(SALOME::SALOME_Exception& e)
   {
-    const char* resource_name = resourceList[i];
-    std::string std_resource_name = resource_name;
-    Engines::ResourceDefinition_var resource_definition
-                             = resManager->GetResourceDefinition(resource_name);
-    int nb_cores = resource_definition->nb_node *
-                   resource_definition->nb_proc_per_node;
-    ret.push_back(std::pair<std::string,int>(resource_name, nb_cores));
+    std::string message;
+    message=e.details.text.in();
+    throw Exception(message);
   }
 
   return ret;