IDE: When receiving SIGTERM signal, kill runtime befor bailing out without saving. wxPython4
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sun, 01 Jan 2023 22:33:29 +0100
branchwxPython4
changeset 3712 cea2005bf2c9
parent 3711 f68449d64d1c
child 3713 cf7c91183995
IDE: When receiving SIGTERM signal, kill runtime befor bailing out without saving.

Purpose is to allow expedited test termination.
BeremizIDE.py
--- a/BeremizIDE.py	Thu Dec 22 02:47:20 2022 +0100
+++ b/BeremizIDE.py	Sun Jan 01 22:33:29 2023 +0100
@@ -30,6 +30,7 @@
 import sys
 import shutil
 import time
+import signal
 from time import time as gettime
 from threading import Lock, Timer, currentThread
 
@@ -508,6 +509,8 @@
         self.RefreshAll()
         self.LogConsole.SetFocus()
 
+        signal.signal(signal.SIGTERM,self.signalTERM_handler)
+
     def RefreshTitle(self):
         name = _("Beremiz")
         if self.CTR is not None:
@@ -644,6 +647,11 @@
             # prevent event to continue, i.e. cancel closing
             event.Veto()
 
+    def signalTERM_handler(self, sig, frame):
+        print ("Signal TERM caught: kill local runtime and quit, no save")
+        self.KillLocalRuntime()
+        sys.exit()
+
     def RefreshFileMenu(self):
         self.RefreshRecentProjectsMenu()