瀏覽代碼

trying to improve reload timing

Rodja Trappe 4 年之前
父節點
當前提交
870243a49c
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      nicegui

+ 4 - 2
nicegui

@@ -46,9 +46,11 @@ while True:
     print_stdout(process)
     if max_mtime > last_mtime:
         last_mtime = max_mtime
-        print(f'Restarting process {process.pid}.')
+        print(f'Restarting {process}.')
+        new = subprocess.Popen(command, shell=True)
+        time.sleep(0.5)
         for child in psutil.Process(process.pid).children(recursive=True):
             child.kill()
         process.kill()
-        process = subprocess.Popen(command, shell=True)
+        process = new
     time.sleep(wait)