SVGHMI: Fix watchdog not cleanly restarting browser because not waiting for stop operation to finish before restarting.
authorEdouard Tisserant <edouard@beremiz.fr>
Tue, 06 Aug 2024 15:25:57 +0200
changeset 4003 65aae40f81dd
parent 4002 6c2b80b4515d
child 4004 19f8192b7d68
SVGHMI: Fix watchdog not cleanly restarting browser because not waiting for stop operation to finish before restarting.
svghmi/svghmi_server.py
--- a/svghmi/svghmi_server.py	Thu Aug 01 12:11:11 2024 +0200
+++ b/svghmi/svghmi_server.py	Tue Aug 06 15:25:57 2024 +0200
@@ -310,9 +310,9 @@
     def waitpid_timeout_loop(proc = proc, timeout = timeout):
         try:
             while proc.poll() is None:
-                time.sleep(1)
-                timeout = timeout - 1
-                if not timeout:
+                time.sleep(.1)
+                timeout = timeout - .1
+                if timeout <= 0:
                     GetPLCObjectSingleton().LogMessage(
                         LogLevelsDict["WARNING"], 
                         "Timeout waiting for {} PID: {}".format(helpstr, str(proc.pid)))
@@ -320,5 +320,5 @@
         except OSError:
             # workaround exception "OSError: [Errno 10] No child processes"
             pass
-    Thread(target=waitpid_timeout_loop, name="Zombie hunter").start()
-
+    waitpid_timeout_loop()
+