string getContainerEntryInNS();
ContainerScriptPerfLog addScript(in string name, in string code);
ListOfContainerScriptPerfLog listOfScripts();
+ void destroy();
};
typedef sequence<ContainerPerfLog> ListOfContainerPerfLog;
{
public:
AutoPyRef(PyObject *pyobj=nullptr):_pyobj(pyobj) { }
- ~AutoPyRef() { release(); }
+ virtual ~AutoPyRef() { release(); }
AutoPyRef(const AutoPyRef& other):_pyobj(other._pyobj) { if(_pyobj) Py_XINCREF(_pyobj); }
AutoPyRef(AutoPyRef&& other) = default;
AutoPyRef& operator=(const AutoPyRef& other) { if(_pyobj==other._pyobj) return *this; release(); _pyobj=other._pyobj; Py_XINCREF(_pyobj); return *this; }
PyObject *get() { return _pyobj; }
bool isNull() const { return _pyobj==0; }
PyObject *retn() { if(_pyobj) Py_XINCREF(_pyobj); return _pyobj; }
-private:
- void release() { if(_pyobj) Py_XDECREF(_pyobj); _pyobj=0; }
+protected:
+ void release() { if(_pyobj) Py_XDECREF(_pyobj); _pyobj=nullptr; }
private:
PyObject *_pyobj = nullptr;
};
+
+class AutoPyRefGilSafe : public AutoPyRef
+{
+public:
+ AutoPyRefGilSafe(PyObject *pyobj=nullptr):AutoPyRef(pyobj) { }
+ ~AutoPyRefGilSafe() { AutoGIL agil; release(); }
+};
std::map<std::string, void *> Abstract_Engines_Container_i::_toRemove_map;
omni_mutex Abstract_Engines_Container_i::_numInstanceMutex ;
-static PyObject* _pyCont;
+static PyObject *_pyCont = nullptr;
int checkifexecutable(const std::string&);
int findpathof(const std::string& path, std::string&, const std::string&);
//
this->cleanAllPyScripts();
//
+ {
+ AutoGIL gstate;
+ AutoPyRef result = PyObject_CallMethod(_pyCont, (char*)"shutdownPy", (char*)"",nullptr);
+ }
+ //
if(_isServantAloneInProcess)
{
MESSAGE("Effective Shutdown of container Begins...");
def monitoringtimeresms(self):
return self._timeIntervalInMs
+ def shutdownPy(self):
+ if getSSLMode():
+ if self._log:
+ self._log.destroy()
+
def setLogFileName(self, logFileName):
logging.debug("setLogFileName {} PID = {}".format(logFileName,os.getpid()))
if getSSLMode():
SALOME_ContainerPerfLog::~SALOME_ContainerPerfLog()
{
- for(auto script : _scripts)
- {
- PortableServer::ServantBase *serv = getPOA()->reference_to_servant(script);
- PortableServer::ObjectId_var oid = getPOA()->reference_to_id(script);
- getPOA()->deactivate_object(oid);
- }
- _scripts.clear();
+ this->destroyInternal();
}
PortableServer::POA_var SALOME_ContainerPerfLog::getPOA()
return ret._retn();
}
+void SALOME_ContainerPerfLog::destroy()
+{
+ this->destroyInternal();
+}
+
+void SALOME_ContainerPerfLog::destroyInternal()
+{
+ _father->removeEntryBeforeDying( this );
+ for(auto script : _scripts)
+ {
+ PortableServer::ServantBase *serv = getPOA()->reference_to_servant(script);
+ PortableServer::ObjectId_var oid = getPOA()->reference_to_id(script);
+ getPOA()->deactivate_object(oid);
+ }
+ _scripts.clear();
+}
+
void SALOME_ContainerPerfLog::accept(SALOME_VisitorContainerLog &visitor)
{
visitor.enterContainerPerfLog( *this );
return CORBA::string_dup( _safe_logger_file_holder.getLastVersionOfFileNameLogger().c_str() );
}
+void SALOME_LogManager::removeEntryBeforeDying(SALOME_ContainerPerfLog *child)
+{
+ for(auto cont = _containers.begin() ; cont != _containers.end() ; ++cont )
+ {
+ PortableServer::ServantBase *serv = getPOA()->reference_to_servant(*cont);
+ SALOME_ContainerPerfLog *servCand = dynamic_cast<SALOME_ContainerPerfLog *>(serv);
+ if( servCand==child )
+ {
+ _containers.erase( cont );
+ break;
+ }
+ }
+}
+
///////////////////////
#include <cstdint>
AutoPyRef end();
void clear() { _data.clear(); }
private:
- AutoPyRef _pyExecutionLog;
+ AutoPyRefGilSafe _pyExecutionLog;
SALOME_ContainerScriptPerfLog *_father = nullptr;
std::vector<char> _data;
};
public:
void accept(SALOME_VisitorContainerLog &visitor);
private:
- AutoPyRef _pyScriptLog;
+ AutoPyRefGilSafe _pyScriptLog;
SALOME_ContainerPerfLog *_father = nullptr;
std::string _name;
std::string _code;
char *getContainerEntryInNS() override;
Engines::ContainerScriptPerfLog_ptr addScript(const char *name, const char *code) override;
Engines::ListOfContainerScriptPerfLog *listOfScripts() override;
+ void destroy() override;
const std::string& nameInNS() const { return _name_in_ns; }
const std::string& logFile() const { return _log_file; }
void setNameInNS(const std::string& name) { _name_in_ns = name; }
public:
void accept(SALOME_VisitorContainerLog &visitor);
private:
- AutoPyRef _pyContLog;
+ void destroyInternal();
+private:
+ AutoPyRefGilSafe _pyContLog;
SALOME_LogManager *_father = nullptr;
std::string _name_in_ns;
std::string _log_file;
void versionA_IsTheLatestValidVersion() override { _safe_logger_file_holder.versionA_IsTheLatestValidVersion(); }
void versionB_IsTheLatestValidVersion() override { _safe_logger_file_holder.versionB_IsTheLatestValidVersion(); }
char *getLastVersionOfFileNameLogger() override;
+ public:
+ void removeEntryBeforeDying(SALOME_ContainerPerfLog *child);
public:
std::size_t getNumberOfContainers() const { return _containers.size(); }
public: