From 0436da711cebf125d8ff38192191592cc14a09f7 Mon Sep 17 00:00:00 2001 From: Gilles DAVID Date: Wed, 27 Sep 2023 18:02:31 +0200 Subject: [PATCH] Fix Python exception --- .../SALOME_DataScopeServer_Common.cxx | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/SALOMESDS/SALOME_DataScopeServer_Common.cxx b/src/SALOMESDS/SALOME_DataScopeServer_Common.cxx index 370c8c36a..7067131d7 100644 --- a/src/SALOMESDS/SALOME_DataScopeServer_Common.cxx +++ b/src/SALOMESDS/SALOME_DataScopeServer_Common.cxx @@ -53,32 +53,34 @@ int CommonDataScopeServerMain(int argc, char *argv[], CORBA::ORB_var orb, const SALOMESDS::DataScopeKiller *killer(new SALOMESDS::DataScopeKiller(orb)); SALOME::DataScopeKiller_var killerObj(killer->_this()); // - SALOME_CPythonHelper cPyHelper; - cPyHelper.initializePython(argc,argv); - // - SALOMESDS::DataScopeServerBase *server(nullptr); - if(!isTransac) - server=new SALOMESDS::DataScopeServer(&cPyHelper,orb,killerObj,scopeName,nsGenrator(orb)); - else - server=new SALOMESDS::DataScopeServerTransaction(&cPyHelper,orb,killerObj,scopeName,nsGenrator(orb)); - // - CORBA::PolicyList policies; - policies.length(3); - PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL)); - policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol); - policies[1]=poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION); - policies[2]=poa->create_id_uniqueness_policy(PortableServer::UNIQUE_ID); - PortableServer::POA_var poa2(poa->create_POA("SingleThPOA4SDS",mgr,policies)); - threadPol->destroy(); - server->registerToSalomePiDict(); - // - server->setPOA(poa2); - obj=server->activate(); - SALOME::DataScopeServerBase_var serverPtr(SALOME::DataScopeServerBase::_narrow(obj)); - server->registerInNS(serverPtr); - // - orb->run(); - delete killer; + { + SALOME_CPythonHelper cPyHelper; + cPyHelper.initializePython(argc,argv); + // + SALOMESDS::DataScopeServerBase *server(nullptr); + if(!isTransac) + server=new SALOMESDS::DataScopeServer(&cPyHelper,orb,killerObj,scopeName,nsGenrator(orb)); + else + server=new SALOMESDS::DataScopeServerTransaction(&cPyHelper,orb,killerObj,scopeName,nsGenrator(orb)); + // + CORBA::PolicyList policies; + policies.length(3); + PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL)); + policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol); + policies[1]=poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION); + policies[2]=poa->create_id_uniqueness_policy(PortableServer::UNIQUE_ID); + PortableServer::POA_var poa2(poa->create_POA("SingleThPOA4SDS",mgr,policies)); + threadPol->destroy(); + server->registerToSalomePiDict(); + // + server->setPOA(poa2); + obj=server->activate(); + SALOME::DataScopeServerBase_var serverPtr(SALOME::DataScopeServerBase::_narrow(obj)); + server->registerInNS(serverPtr); + // + orb->run(); + delete killer; + } Py_Finalize(); return 0; } -- 2.39.2