[openrtm-commit:02542] r806 - trunk/OpenRTM-aist-Python/OpenRTM_aist

openrtm @ openrtm.org openrtm @ openrtm.org
2017年 3月 31日 (金) 00:12:04 JST


Author: miyamoto
Date: 2017-03-31 00:12:04 +0900 (Fri, 31 Mar 2017)
New Revision: 806

Modified:
   trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py
   trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py
Log:
[compat,bugfix,->RELENG_1_2] fixed bug.

Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py	2017-03-08 02:41:53 UTC (rev 805)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py	2017-03-30 15:12:04 UTC (rev 806)
@@ -95,6 +95,30 @@
 
 ##
 # @if jp
+# @brief マネージャ終了スレッド生成
+#
+# 
+#
+#
+# @else
+#
+# @endif
+class terminate_Task(OpenRTM_aist.Task):
+  ##
+  # @brief コンストラクタ
+  # @param self
+  # @param mgr マネージャ
+  # @param sleep_time 待機時間
+  def __init__(self, mgr, sleep_time):
+    OpenRTM_aist.Task.__init__(self)
+    self._mgr = mgr
+    self._sleep_time = sleep_time
+  def svc(self):
+    time.sleep(self._sleep_time)
+    self._mgr.terminate()
+
+##
+# @if jp
 # @class Manager
 # @brief Manager クラス
 #
@@ -129,7 +153,7 @@
     self._initProc   = None
     self._runner     = None
     self._terminator = None
-    self.shutdown_thread = None
+    self._shutdown_thread = None
     self._compManager = OpenRTM_aist.ObjectManager(self.InstanceName)
     self._factory = OpenRTM_aist.ObjectManager(self.FactoryPredicate)
     self._ecfactory = OpenRTM_aist.ObjectManager(self.ECFactoryPredicate)
@@ -493,7 +517,9 @@
         self.join()
       except:
         self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
-
+      if self._shutdown_thread:
+        self._shutdown_thread.wait()
+    
     return
 
 
@@ -1433,8 +1459,7 @@
       comps = self.getComponents()
       
       if len(comps) == 0:
-        self.shutdown_thread = threading.Thread(target=self.shutdown)
-        self.shutdown_thread.start()
+        self.createShutdownThread()
 
     return
 
@@ -3126,8 +3151,27 @@
     self._rtcout.RTC_TRACE("Manager.getNaming()")
     return self._namingManager
 
+  ##
+  # @if jp
+  # @brief マネージャ終了スレッド生成
+  # 
+  # 
+  # @param self
+  # @param sleep_time 待機時間
+  # @return task
+  # @else
+  #
+  # @brief 
+  # @param self
+  # @param sleep_time 
+  # @return task
+  # @endif
+  def createShutdownThread(self, sleep_time=0):
+    self._rtcout.RTC_TRACE("Manager.createShutdownThread()")
+    self._shutdown_thread = terminate_Task(self, sleep_time)
+    self._shutdown_thread.activate()
+    return self._shutdown_thread
 
-
   #============================================================
   # コンポーネントマネージャ
   #============================================================

Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py	2017-03-08 02:41:53 UTC (rev 805)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py	2017-03-30 15:12:04 UTC (rev 806)
@@ -24,15 +24,9 @@
 
 
 
-class terminate_Task(OpenRTM_aist.Task):
-  def __init__(self, mgr):
-    OpenRTM_aist.Task.__init__(self)
-    self._mgr = mgr
-  def svc(self):
-    time.sleep(1)
-    self._mgr.terminate()
 
 
+
 class ManagerServant(RTM__POA.Manager):
   """
   """
@@ -60,6 +54,7 @@
     self._masterMutex = threading.RLock()
     self._slaveMutex = threading.RLock()
     self._objref = None
+    
 
     config = copy.deepcopy(self._mgr.getConfig())
 
@@ -803,8 +798,8 @@
   #
   # ReturnCode_t shutdown()
   def shutdown(self):
-    task = terminate_Task(self._mgr)
-    task.activate()
+    self._mgr.createShutdownThread(1)
+    
     return RTC.RTC_OK
 
   



openrtm-commit メーリングリストの案内