From 99aa339bbfaa24f3d643fde36ce1992ae2bdd1ef Mon Sep 17 00:00:00 2001 From: JackDandy Date: Sun, 5 Mar 2023 22:52:09 +0000 Subject: [PATCH] Add logging around the restart/shutdown event. --- CHANGES.md | 4 ++++ sickgear.py | 1 + sickgear/__init__.py | 3 +++ sickgear/event_queue.py | 10 ++++++++++ 4 files changed, 18 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 81e9d159..dc0f5f5c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,10 @@ * Change requirements for pure py3 * Change codebase cleanups +[develop changelog] + +* Add logging around the restart/shutdown event + ### 3.27.11 (2023-03-06 23:40:00 UTC) diff --git a/sickgear.py b/sickgear.py index d15ad247..4ccb25de 100755 --- a/sickgear.py +++ b/sickgear.py @@ -769,6 +769,7 @@ class SickGear(object): return False def shutdown(self, ev_type): + logger.debug(f'Shutdown ev_type:{ev_type}, sickgear.started:{sickgear.started}') if sickgear.started: # stop all tasks sickgear.halt() diff --git a/sickgear/__init__.py b/sickgear/__init__.py index 3d7be274..53d7e3b7 100644 --- a/sickgear/__init__.py +++ b/sickgear/__init__.py @@ -1747,6 +1747,7 @@ def restart(soft=True, update_pkg=None): if update_pkg: MY_ARGS.append('--update-pkg') + logger.log(u'Trigger event restart') events.put(events.SystemEvent.RESTART) else: @@ -1770,8 +1771,10 @@ def sig_handler(signum=None, _=None): def halt(): global __INITIALIZED__, started + logger.debug('Check INIT_LOCK on halt') with INIT_LOCK: + logger.debug(f'Check __INITIALIZED__ on halt: {__INITIALIZED__}') if __INITIALIZED__: logger.log('Exiting threads') diff --git a/sickgear/event_queue.py b/sickgear/event_queue.py index 2975c380..0c894e00 100644 --- a/sickgear/event_queue.py +++ b/sickgear/event_queue.py @@ -32,7 +32,17 @@ class Events(threading.Thread): try: # get event type etype = self.queue.get(True, 1) + except moves.queue.Empty: + etype = 'Empty' + except(BaseException, Exception): + etype = None + if etype in (self.SystemEvent.RESTART, self.SystemEvent.SHUTDOWN, None, 'Empty'): + if etype in ('Empty',): + continue + from sickgear import logger + logger.debug(f'Callback {self.callback.__name__}(event type:{etype})') + try: # perform callback if we got an event type self.callback(etype)