Ver código fonte

Merge pull request #602 from al-eax/exit_native_mode

Fix: Exception when closing native mode window on Windows
Rodja Trappe 2 anos atrás
pai
commit
acafb58388
1 arquivos alterados com 3 adições e 4 exclusões
  1. 3 4
      nicegui/native_mode.py

+ 3 - 4
nicegui/native_mode.py

@@ -1,3 +1,4 @@
+import _thread
 import multiprocessing
 import os
 import signal
@@ -24,10 +25,8 @@ def activate(url: str, title: str, width: int, height: int, fullscreen: bool) ->
     shutdown = multiprocessing.Event()
 
     def check_shutdown() -> None:
-        while True:
-            if shutdown.is_set():
-                os.kill(os.getpgid(os.getpid()), signal.SIGTERM)
-            time.sleep(0.1)
+        if shutdown.wait() and shutdown.is_set():
+            _thread.interrupt_main()
 
     args = url, title, width, height, fullscreen, shutdown
     multiprocessing.Process(target=open_window, args=args, daemon=False).start()