# HG changeset patch
# User Edouard Tisserant <edouard@beremiz.fr>
# Date 1722950757 -7200
# Node ID 65aae40f81ddfe1744c1cd332fe1f879fd98ad43
# Parent  6c2b80b4515d76403610c2830d043d2205589da2
SVGHMI: Fix watchdog not cleanly restarting browser because not waiting for stop operation to finish before restarting.

diff -r 6c2b80b4515d -r 65aae40f81dd 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()
+