SVGHMI: Fix watchdog exception on windows
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Mon, 09 Oct 2023 16:42:59 +0200
changeset 3864 3e434edfbfdf
parent 3863 b076f52bd1c8
child 3865 c1754cd1c298
SVGHMI: Fix watchdog exception on windows
svghmi/svghmi_server.py
--- a/svghmi/svghmi_server.py	Mon Oct 09 16:42:11 2023 +0200
+++ b/svghmi/svghmi_server.py	Mon Oct 09 16:42:59 2023 +0200
@@ -307,15 +307,15 @@
 def waitpid_timeout(proc, helpstr="", timeout = 3):
     if proc is None:
         return
-    def waitpid_timeout_loop(pid=proc.pid, timeout = timeout):
+    def waitpid_timeout_loop(proc = proc, timeout = timeout):
         try:
-            while os.waitpid(pid,os.WNOHANG) == (0,0):
+            while proc.poll() is None:
                 time.sleep(1)
                 timeout = timeout - 1
                 if not timeout:
                     GetPLCObjectSingleton().LogMessage(
                         LogLevelsDict["WARNING"], 
-                        "Timeout waiting for {} PID: {}".format(helpstr, str(pid)))
+                        "Timeout waiting for {} PID: {}".format(helpstr, str(proc.pid)))
                     break
         except OSError:
             # workaround exception "OSError: [Errno 10] No child processes"