Shutdown fixes
- tell sql thread to finish only after the other threads finished - prevents other threads stalling on sql replies
This commit is contained in:
parent
12117ada99
commit
54c37150e0
|
@ -35,22 +35,24 @@ def doCleanShutdown():
|
||||||
while state.shutdown == 1:
|
while state.shutdown == 1:
|
||||||
time.sleep(.1)
|
time.sleep(.1)
|
||||||
|
|
||||||
|
# Wait long enough to guarantee that any running proof of work worker threads will check the
|
||||||
|
# shutdown variable and exit. If the main thread closes before they do then they won't stop.
|
||||||
|
time.sleep(.25)
|
||||||
|
|
||||||
|
for thread in threading.enumerate():
|
||||||
|
if (thread is not threading.currentThread() and
|
||||||
|
isinstance(thread, StoppableThread) and
|
||||||
|
thread.name != 'SQL'):
|
||||||
|
logger.debug("Waiting for thread %s", thread.name)
|
||||||
|
thread.join()
|
||||||
|
|
||||||
# This one last useless query will guarantee that the previous flush committed and that the
|
# This one last useless query will guarantee that the previous flush committed and that the
|
||||||
# objectProcessorThread committed before we close the program.
|
# objectProcessorThread committed before we close the program.
|
||||||
sqlQuery('SELECT address FROM subscriptions')
|
sqlQuery('SELECT address FROM subscriptions')
|
||||||
logger.info('Finished flushing inventory.')
|
logger.info('Finished flushing inventory.')
|
||||||
sqlStoredProcedure('exit')
|
sqlStoredProcedure('exit')
|
||||||
|
|
||||||
# Wait long enough to guarantee that any running proof of work worker threads will check the
|
# flush queues
|
||||||
# shutdown variable and exit. If the main thread closes before they do then they won't stop.
|
|
||||||
time.sleep(.25)
|
|
||||||
|
|
||||||
for thread in threading.enumerate():
|
|
||||||
if thread is not threading.currentThread() and isinstance(thread, StoppableThread):
|
|
||||||
logger.debug("Waiting for thread %s", thread.name)
|
|
||||||
thread.join()
|
|
||||||
|
|
||||||
# flush queued
|
|
||||||
for queue in (workerQueue, UISignalQueue, addressGeneratorQueue, objectProcessorQueue):
|
for queue in (workerQueue, UISignalQueue, addressGeneratorQueue, objectProcessorQueue):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user