shutdown quality fixes

This commit is contained in:
lakshyacis 2019-10-22 19:54:04 +05:30
parent 6f91ba1b33
commit 503d0b33d0
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB
1 changed files with 5 additions and 5 deletions

View File

@ -1,3 +1,4 @@
"""shutdown function"""
import os import os
import Queue import Queue
import threading import threading
@ -15,8 +16,7 @@ from queues import (
def doCleanShutdown(): def doCleanShutdown():
# Used to tell proof of work worker threads """Used to tell proof of work worker threads and the objectProcessorThread to exit."""
# and the objectProcessorThread to exit.
state.shutdown = 1 state.shutdown = 1
objectProcessorQueue.put(('checkShutdownVariable', 'no data')) objectProcessorQueue.put(('checkShutdownVariable', 'no data'))
@ -53,7 +53,7 @@ def doCleanShutdown():
for thread in threading.enumerate(): for thread in threading.enumerate():
if (thread is not threading.currentThread() and if (thread is not threading.currentThread() and
isinstance(thread, StoppableThread) and isinstance(thread, StoppableThread) and
thread.name != 'SQL'): thread.name != 'SQL'):
logger.debug("Waiting for thread %s", thread.name) logger.debug("Waiting for thread %s", thread.name)
thread.join() thread.join()
@ -76,10 +76,10 @@ def doCleanShutdown():
except Queue.Empty: except Queue.Empty:
break break
if shared.thisapp.daemon or not state.enableGUI: # FIXME redundant? if shared.thisapp.daemon or not state.enableGUI: # ..fixme:: redundant?
logger.info('Clean shutdown complete.') logger.info('Clean shutdown complete.')
shared.thisapp.cleanup() shared.thisapp.cleanup()
os._exit(0) os._exit(0) # pylint: disable=protected-access
else: else:
logger.info('Core shutdown complete.') logger.info('Core shutdown complete.')
for thread in threading.enumerate(): for thread in threading.enumerate():