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

View File

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