Runtime now unloads and cleanup PLC before exit (created threads was preventing exit)
authorEdouard Tisserant
Fri, 19 Apr 2013 11:19:55 +0900
changeset 1045 a220a27defe5
parent 1044 41bd726aa23c
child 1046 103467ccb22f
Runtime now unloads and cleanup PLC before exit (created threads was preventing exit)
Beremiz_service.py
runtime/PLCObject.py
--- a/Beremiz_service.py	Fri Apr 19 01:44:25 2013 +0200
+++ b/Beremiz_service.py	Fri Apr 19 11:19:55 2013 +0900
@@ -465,6 +465,8 @@
 
     def Quit(self):
         self.continueloop = False
+        if self.plcobj is not None:
+            self.plcobj.UnLoadPLC()
         self.Stop()
 
     def Start(self):
@@ -496,7 +498,8 @@
         self.daemon.requestLoop()
     
     def Stop(self):
-        self.plcobj.StopPLC()
+        if self.plcobj is not None:
+            self.plcobj.StopPLC()
         if self.servicepublisher is not None:
             self.servicepublisher.UnRegisterService()
             self.servicepublisher = None
--- a/runtime/PLCObject.py	Fri Apr 19 01:44:25 2013 +0200
+++ b/runtime/PLCObject.py	Fri Apr 19 11:19:55 2013 +0900
@@ -205,6 +205,10 @@
             PLCprint(self._loading_error)
             return False
 
+    def UnLoadPLC(self):
+        self.PythonRuntimeCleanup()
+        self._FreePLC()
+
     def _FreePLC(self):
         """
         Unload PLC library.
@@ -363,9 +367,8 @@
             NewFileName = md5sum + lib_ext
             extra_files_log = os.path.join(self.workingdir,"extra_files.txt")
 
-            self.PythonRuntimeCleanup()
-
-            self._FreePLC()
+            self.UnLoadPLC()
+
             self.LogMessage("NewPLC (%s)"%md5sum)
             self.PLCStatus = "Empty"