Merge branch 'feature/AddShutdownLogs' into dev

This commit is contained in:
JackDandy 2023-03-06 23:52:58 +00:00
commit 40f09ea79a
4 changed files with 18 additions and 0 deletions

View file

@ -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)

View file

@ -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()

View file

@ -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')

View file

@ -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)