Salome HOME
evalyfx supports now non python created thread outside salome context
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 20 Jul 2016 08:27:42 +0000 (10:27 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 20 Jul 2016 08:27:42 +0000 (10:27 +0200)
src/evalyfx/YACSEvalSession.cxx
src/evalyfx/YACSEvalSession.hxx
src/evalyfx/YACSEvalYFXPattern.cxx
src/evalyfx_swig/evalyfx.i

index f89f076c0351bc2b22dc526227f5ea2a44a10e71..69039c3a1eea4d40c85151cfc7067e8f6b7599b5 100644 (file)
@@ -34,7 +34,7 @@ const char YACSEvalSession::CORBA_CONFIG_ENV_VAR_NAME[]="OMNIORB_CONFIG";
 
 const char YACSEvalSession::NSPORT_VAR_NAME[]="NSPORT";
 
-YACSEvalSession::YACSEvalSession():_isAttached(false),_isLaunched(false),_port(-1),_salomeInstanceModule(0),_salomeInstance(0),_internal(new YACSEvalSessionInternal)
+YACSEvalSession::YACSEvalSession():_isAttached(false),_isLaunched(false),_isForcedPyThreadSaved(false),_port(-1),_salomeInstanceModule(0),_salomeInstance(0),_internal(new YACSEvalSessionInternal)
 {
   if(!Py_IsInitialized())
     Py_Initialize();
@@ -88,6 +88,14 @@ void YACSEvalSession::launchUsingCurrentSession()
   _isAttached=true; _isLaunched=true;
 }
 
+bool YACSEvalSession::isAlreadyPyThreadSaved() const
+{
+  if(!_isForcedPyThreadSaved)
+    return isAttached();
+  else
+    return true;
+}
+
 void YACSEvalSession::checkLaunched() const
 {
   if(!isLaunched())
index 1b0f60414d485556093b1a7d317fd731ab18706d..94f70bcf7ceece6ffd45cec67bfa978349c83770 100644 (file)
@@ -39,6 +39,11 @@ public:
   YACSEVALYFX_EXPORT void launchUsingCurrentSession();
   YACSEVALYFX_EXPORT bool isLaunched() const { return _isLaunched; }
   YACSEVALYFX_EXPORT bool isAttached() const { return _isAttached; }
+  //
+  YACSEVALYFX_EXPORT bool isAlreadyPyThreadSaved() const;
+  YACSEVALYFX_EXPORT bool getForcedPyThreadSavedStatus() const { return _isForcedPyThreadSaved; }
+  YACSEVALYFX_EXPORT void setForcedPyThreadSavedStatus(bool status) { _isForcedPyThreadSaved=status; }
+  //
   YACSEVALYFX_EXPORT void checkLaunched() const;
   YACSEVALYFX_EXPORT int getPort() const;
   YACSEVALYFX_EXPORT std::string getCorbaConfigFileName() const;
@@ -54,6 +59,7 @@ public:
 private:
   bool _isAttached;
   bool _isLaunched;
+  bool _isForcedPyThreadSaved;
   int _port;
   std::string _corbaConfigFileName;
   PyObject *_salomeInstanceModule;
index 8da34b14f8653e48292cead5ed4e36b9bc576c43..634c4bf6bdf45b9a15bc758d15e458e75e2c3846 100644 (file)
@@ -812,7 +812,7 @@ bool YACSEvalYFXGraphGenInteractive::go(bool stopASAP, YACSEvalSession *session)
   YACS::ENGINE::Executor exe;
   exe.setKeepGoingProperty(!stopASAP);
   {
-    MyAutoThreadSaver locker(!session->isAttached());
+    MyAutoThreadSaver locker(!session->isAlreadyPyThreadSaved());
     exe.RunW(getUndergroundGeneratedGraph());
   }
   return getUndergroundGeneratedGraph()->getState()==YACS::DONE;
index 959ff159e3304f2dc70be4d0835565bbdd032073..47625c3d7773f5e8db17bcf23501871c59271887 100644 (file)
@@ -395,6 +395,9 @@ public:
   void launch();
   bool isLaunched() const;
   bool isAttached() const;
+  bool isAlreadyPyThreadSaved() const;
+  bool getForcedPyThreadSavedStatus() const;
+  void setForcedPyThreadSavedStatus(bool status);
   void checkLaunched() const;
   int getPort() const;
   std::string getCorbaConfigFileName() const;