mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 14:42:54 +01:00
feat: set exit event on SIGINT
This commit is contained in:
1 parent
90f818f462
commit
0aafe44b4e
3 files changed
+17
-4
No files matched your search
+10
-2
@@ -1,7 +1,7 @@
|
|||||||
import inspect
|
|
||||||
import logging
|
import logging
|
||||||
|
import threading
|
||||||
|
|
||||||
from typing import Any, Callable, TYPE_CHECKING
|
from typing import Any, TYPE_CHECKING
|
||||||
|
|
||||||
import dzgui.util._json as JSON # noqa
|
import dzgui.util._json as JSON # noqa
|
||||||
|
|
||||||
@@ -84,6 +84,8 @@ class Controller(GObject.GObject):
|
|||||||
self.loaded = False
|
self.loaded = False
|
||||||
self.pending_jobs = 1
|
self.pending_jobs = 1
|
||||||
|
|
||||||
|
self.exit_event = threading.Event()
|
||||||
|
|
||||||
def get_emitter(self) -> Emitter:
|
def get_emitter(self) -> Emitter:
|
||||||
return self.emitter
|
return self.emitter
|
||||||
|
|
||||||
@@ -442,3 +444,9 @@ class Controller(GObject.GObject):
|
|||||||
|
|
||||||
def get_modtreeview(self) -> "ModTreeView":
|
def get_modtreeview(self) -> "ModTreeView":
|
||||||
return self.mediator.modtreeview
|
return self.mediator.modtreeview
|
||||||
|
|
||||||
|
def set_exit_event(self) -> None:
|
||||||
|
self.exit_event.set()
|
||||||
|
|
||||||
|
def get_exit_event(self) -> None:
|
||||||
|
return self.exit_event
|
||||||
@@ -91,6 +91,12 @@ class ServerModelManager:
|
|||||||
futures = [executor.submit(job, key, APPID_DAYZ, param) for param in params]
|
futures = [executor.submit(job, key, APPID_DAYZ, param) for param in params]
|
||||||
for future in as_completed(futures):
|
for future in as_completed(futures):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
# NOTE: faciliate early aborting on boot via sigint
|
||||||
|
# this logic not available outside of initial boot
|
||||||
|
if self.controller.get_exit_event().is_set():
|
||||||
|
return
|
||||||
|
|
||||||
self.thread_man.increment_dialog()
|
self.thread_man.increment_dialog()
|
||||||
res = future.result(timeout=API_TIMEOUT)
|
res = future.result(timeout=API_TIMEOUT)
|
||||||
if res.status != 200 or not res.parsed:
|
if res.status != 200 or not res.parsed:
|
||||||
@@ -101,7 +107,6 @@ class ServerModelManager:
|
|||||||
j = res.json
|
j = res.json
|
||||||
servers += j["response"]["servers"]
|
servers += j["response"]["servers"]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# TODO: could store exception in cleanup func
|
|
||||||
logger.critical(e)
|
logger.critical(e)
|
||||||
self.thread_man.set_cleanup_func(
|
self.thread_man.set_cleanup_func(
|
||||||
StoredFunc(self._cleanup_on_failure)
|
StoredFunc(self._cleanup_on_failure)
|
||||||
|
|||||||
+1
-1
@@ -94,7 +94,6 @@ class OuterWindow(Gtk.Window):
|
|||||||
self.halt_proc_and_quit()
|
self.halt_proc_and_quit()
|
||||||
|
|
||||||
def halt_proc_and_quit(self) -> None:
|
def halt_proc_and_quit(self) -> None:
|
||||||
# MainController.terminate_process()
|
|
||||||
MainController.save_res_and_quit()
|
MainController.save_res_and_quit()
|
||||||
|
|
||||||
|
|
||||||
@@ -319,6 +318,7 @@ class App(Gtk.Application):
|
|||||||
logger.critical(e)
|
logger.critical(e)
|
||||||
|
|
||||||
def _catch_sigint(self) -> Literal[True]:
|
def _catch_sigint(self) -> Literal[True]:
|
||||||
|
MainController.set_exit_event()
|
||||||
self.win.halt_proc_and_quit()
|
self.win.halt_proc_and_quit()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user