Runtime: Fix PLC python thread crash in case of exception in PostStart customization hook.
authorEdouard Tisserant
Tue, 02 Aug 2022 11:53:37 +0200
changeset 3578 d74eb1be6abe
parent 3577 6c7a7b22bec9
child 3579 c5070b6973ba
Runtime: Fix PLC python thread crash in case of exception in PostStart customization hook.
runtime/PLCObject.py
--- a/runtime/PLCObject.py	Tue Aug 02 11:50:54 2022 +0200
+++ b/runtime/PLCObject.py	Tue Aug 02 11:53:37 2022 +0200
@@ -466,7 +466,7 @@
                 self.PythonThreadAcknowledge(cmd)
                 self.PythonRuntimeCall("start")
                 self.LogMessage("Python extensions started")
-                self.PostStartPLC()
+                self._PostStartPLC()
                 self.PythonThreadLoop()
                 self.PythonRuntimeCall("stop", reverse_order=True)
             elif cmd == "Finish":
@@ -504,6 +504,13 @@
         """
         pass
 
+    def _PostStartPLC(self):
+        try:
+            self.PostStartPLC()
+        except Exception:
+            self.LogMessage(0, 'Post Start Exception'+'\n'.join(
+                traceback.format_exception(*sys.exc_info())))
+
     def PostStartPLC(self):
         """ 
         Here goes actions to be taken after PLC is started,