Added custom exception hook for logging; removed cruft; added shutdown signal
This commit is contained in:
parent
43d0881a36
commit
37d7075079
|
@ -1,6 +1,7 @@
|
||||||
# Python imports
|
# Python imports
|
||||||
import builtins
|
import builtins
|
||||||
import threading
|
import threading
|
||||||
|
import sys
|
||||||
|
|
||||||
# Lib imports
|
# Lib imports
|
||||||
|
|
||||||
|
@ -13,10 +14,6 @@ from utils.logger import Logger
|
||||||
from utils.settings_manager.manager import SettingsManager
|
from utils.settings_manager.manager import SettingsManager
|
||||||
|
|
||||||
|
|
||||||
class BuiltinsException(Exception):
|
|
||||||
...
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# NOTE: Threads WILL NOT die with parent's destruction.
|
# NOTE: Threads WILL NOT die with parent's destruction.
|
||||||
def threaded_wrapper(fn):
|
def threaded_wrapper(fn):
|
||||||
|
@ -51,4 +48,14 @@ builtins.logger = Logger(settings_manager.get_home_config_path(), \
|
||||||
|
|
||||||
builtins.threaded = threaded_wrapper
|
builtins.threaded = threaded_wrapper
|
||||||
builtins.daemon_threaded = daemon_threaded_wrapper
|
builtins.daemon_threaded = daemon_threaded_wrapper
|
||||||
builtins.event_sleep_time = 0.05
|
|
||||||
|
|
||||||
|
|
||||||
|
def custom_except_hook(exc_type, exc_value, exc_traceback):
|
||||||
|
if issubclass(exc_type, KeyboardInterrupt):
|
||||||
|
sys.__excepthook__(exc_type, exc_value, exc_traceback)
|
||||||
|
return
|
||||||
|
|
||||||
|
logger.error("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback))
|
||||||
|
|
||||||
|
sys.excepthook = custom_except_hook
|
||||||
|
|
|
@ -48,6 +48,7 @@ class Controller(DummyMixin, SignalsMixins, ControllerData):
|
||||||
self.window.connect("key-release-event", self.on_global_key_release_controller)
|
self.window.connect("key-release-event", self.on_global_key_release_controller)
|
||||||
|
|
||||||
def _subscribe_to_events(self):
|
def _subscribe_to_events(self):
|
||||||
|
event_system.subscribe("shutting_down", lambda: print("Shutting down..."))
|
||||||
event_system.subscribe("handle_file_from_ipc", self.handle_file_from_ipc)
|
event_system.subscribe("handle_file_from_ipc", self.handle_file_from_ipc)
|
||||||
event_system.subscribe("handle_dir_from_ipc", self.handle_dir_from_ipc)
|
event_system.subscribe("handle_dir_from_ipc", self.handle_dir_from_ipc)
|
||||||
event_system.subscribe("tggl_top_main_menubar", self._tggl_top_main_menubar)
|
event_system.subscribe("tggl_top_main_menubar", self._tggl_top_main_menubar)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# Python imports
|
# Python imports
|
||||||
import time
|
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
# Lib imports
|
# Lib imports
|
||||||
|
@ -99,6 +98,8 @@ class Window(Gtk.ApplicationWindow):
|
||||||
|
|
||||||
|
|
||||||
def _tear_down(self, widget = None, eve = None):
|
def _tear_down(self, widget = None, eve = None):
|
||||||
|
event_system.emit("shutting_down")
|
||||||
|
|
||||||
size = self.get_default_size()
|
size = self.get_default_size()
|
||||||
pos = self.get_position()
|
pos = self.get_position()
|
||||||
|
|
||||||
|
@ -109,5 +110,4 @@ class Window(Gtk.ApplicationWindow):
|
||||||
settings_manager.save_settings()
|
settings_manager.save_settings()
|
||||||
|
|
||||||
settings_manager.clear_pid()
|
settings_manager.clear_pid()
|
||||||
time.sleep(event_sleep_time)
|
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
|
|
Loading…
Reference in New Issue