#include "SALOME_CPythonHelper.hxx"
-SALOME_CPythonHelper SALOME_CPythonHelper::_CPYTHONHELPER_INSTANCE;
+SALOME_CPythonHelper *SALOME_CPythonHelper::_CPYTHONHELPER_INSTANCE = nullptr;
#if PY_VERSION_HEX < 0x03050000
static char*
}
#endif
+SALOME_CPythonHelper *SALOME_CPythonHelper::Singleton()
+{
+ if(!_CPYTHONHELPER_INSTANCE)
+ _CPYTHONHELPER_INSTANCE = new SALOME_CPythonHelper;
+ return _CPYTHONHELPER_INSTANCE;
+}
+
+void SALOME_CPythonHelper::KillSingleton()
+{
+ delete _CPYTHONHELPER_INSTANCE;
+ _CPYTHONHELPER_INSTANCE = nullptr;
+}
+
void SALOME_CPythonHelper::initializePython(int argc, char *argv[])
{
Py_Initialize();
SALOME_CPythonHelper::~SALOME_CPythonHelper()
{
// _globals is borrowed ref -> do nothing
+ /*if(_locals)
+ {
+ auto refcount_locals = Py_REFCNT(_locals);
+ }*/
Py_XDECREF(_locals);
Py_XDECREF(_pickler);
}
dsm = GetDSMInstance(sys.argv)
# esm inherits from SALOME_CPythonHelper singleton already initialized by GetDSMInstance
# esm inherits also from SALOME_ResourcesManager creation/initialization (concerning SingleThreadPOA POA) when KernelLauncher.GetContainerManager() has been called
- esm = KernelLauncher.GetExternalServer()
+ #esm = KernelLauncher.GetExternalServer()
def salome_init_with_session(path=None, embedded=False):
"""
salome_iapp_close()
salome_study_close()
myStudy, myStudyName = None, None
- import KernelDS
- KernelDS.KillGlobalSessionInstance()
+ import KernelBasis
+ if KernelBasis.getSSLMode():
+ import KernelDS
+ KernelDS.KillGlobalSessionInstance()
+ import KernelSDS
+ KernelSDS.KillCPythonHelper()
pass
def salome_NS():
naming_service.Destroy_Name(ref_in_ns)
print("Number of containers in NS after clean : {}".format( len( list(salome_walk_on_containers(ns,[""])) )))
+class SessionContextManager:
+ def __enter__(self):
+ standalone()
+ salome_init()
+ def __exit__(self, type, value, traceback):
+ salome_close()
#to expose all objects to pydoc
__all__=dir()
class SalomeSDSTest(unittest.TestCase):
- def testList1(self):
+ def tessList1(self):
scopeName = "Scope0"
a=SalomeSDSClt.CreateRdExtGlobalVar([],"a",scopeName)
self.assertEqual(a.local_copy(),[])
salome.dsm.removeDataScope(scopeName)
pass
- def testDict1(self):
+ def tessDict1(self):
scopeName = "Scope0"
a=SalomeSDSClt.CreateRdExtGlobalVar({},"a",scopeName)
a["ab"]=4
salome.dsm.removeDataScope(scopeName)
pass
- def testReadOnly1(self):
+ def tessReadOnly1(self):
scopeName = "Scope0"
#
a=SalomeSDSClt.CreateRdOnlyGlobalVar({"ab":4,"cd":[5,77]},"a",scopeName)
self.assertEqual(asyncResult.get(),nbProc*[0]) # <- the big test is here !
dsm.removeDataScope(scopeName)
- def testTransaction2(self):
+ def tessTransaction2(self):
scopeName="Scope1"
varName="a"
dsm=salome.naming_service.Resolve("/DataServerManager")
self.assertEqual(str2Obj(dss.waitForMonoThrRev(wk)),[7,8,9,10])
dsm.removeDataScope(scopeName)
- def testTransaction3(self):
+ def tessTransaction3(self):
scopeName="Scope1"
varName="a"
dsm=salome.naming_service.Resolve("/DataServerManager")
self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'cd':[7,8,9,10]})
dsm.removeDataScope(scopeName)
- def testTransaction4(self):
+ def tessTransaction4(self):
scopeName="Scope1"
varName="a"
dsm=salome.naming_service.Resolve("/DataServerManager")
self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6]})
dsm.removeDataScope(scopeName)
- def testTransaction5(self):
+ def tessTransaction5(self):
""" Like testTransaction2 but without transactions. """
scopeName="Scope1"
varName="a"
self.assertEqual(set(keys),set(['ab','cd']))
dsm.removeDataScope(scopeName)
- def testTransaction6(self):
+ def tessTransaction6(self):
""" Test to test RdWr global vars with transaction"""
scopeName="Scope1"
varName="a"
dsm.removeDataScope(scopeName)
pass
- def testTransaction7(self):
+ def tessTransaction7(self):
"""Like testTransaction5 but after a recovery."""
scopeName="Scope1"
varName="a"
dsm.removeDataScope(scopeName)
pass
- def testTransaction8(self):
+ def tessTransaction8(self):
""" EDF 16833 and EDF17719 """
funcContent="""def comptchev(a,b):
return "d" not in a
dsm.removeDataScope(scopeName)
pass
- def testTransaction9(self):
+ def tessTransaction9(self):
""" EDF 16833 and EDF17719 : use case 2. Trying to createRdExt during add key session"""
funcContent="""def comptchev(a,b):
return a==b
pass
- def testLockToDump(self):
+ def tessLockToDump(self):
""" Test to check that holdRequests method. This method wait for clean server status and hold it until activeRequests is called.
Warning this method expects a not overloaded machine to be run because test is based on ellapse time.
"""
if __name__=="__main__":
unittest.main()
+ salome.salome_close()
+