Просмотр исходного кода

trying to improve reload timing

Rodja Trappe 4 лет назад
Родитель
Сommit
870243a49c
1 измененных файлов с 4 добавлено и 2 удалено
  1. 4 2
      nicegui

+ 4 - 2
nicegui

@@ -46,9 +46,11 @@ while True:
     print_stdout(process)
     print_stdout(process)
     if max_mtime > last_mtime:
     if max_mtime > last_mtime:
         last_mtime = max_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):
         for child in psutil.Process(process.pid).children(recursive=True):
             child.kill()
             child.kill()
         process.kill()
         process.kill()
-        process = subprocess.Popen(command, shell=True)
+        process = new
     time.sleep(wait)
     time.sleep(wait)