singleWorker shutdown fix
if singleWorker crashed, the thread couldn't be joined. This both makes it so that it doesn't crash, as well as reorders the shutdown sequence so that it is less likely to be triggered. Fixes Bitmessage#549
This commit is contained in:
parent
ec4a16b388
commit
32b0d24be2
|
@ -71,18 +71,19 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
self.stop.wait(
|
self.stop.wait(
|
||||||
10) # give some time for the GUI to start before we start on existing POW tasks.
|
10) # give some time for the GUI to start before we start on existing POW tasks.
|
||||||
|
|
||||||
queryreturn = sqlQuery(
|
if shared.shutdown == 0:
|
||||||
'''SELECT DISTINCT toaddress FROM sent WHERE (status='doingpubkeypow' AND folder='sent')''')
|
queryreturn = sqlQuery(
|
||||||
for row in queryreturn:
|
'''SELECT DISTINCT toaddress FROM sent WHERE (status='doingpubkeypow' AND folder='sent')''')
|
||||||
toaddress, = row
|
for row in queryreturn:
|
||||||
self.requestPubKey(toaddress)
|
toaddress, = row
|
||||||
|
logger.debug("c: %s", shared.shutdown)
|
||||||
self.sendMsg()
|
self.requestPubKey(toaddress)
|
||||||
# just in case there are any pending tasks for msg
|
# just in case there are any pending tasks for msg
|
||||||
# messages that have yet to be sent.
|
# messages that have yet to be sent.
|
||||||
self.sendBroadcast()
|
self.sendMsg()
|
||||||
# just in case there are any tasks for Broadcasts
|
# just in case there are any tasks for Broadcasts
|
||||||
# that have yet to be sent.
|
# that have yet to be sent.
|
||||||
|
self.sendBroadcast()
|
||||||
|
|
||||||
while shared.shutdown == 0:
|
while shared.shutdown == 0:
|
||||||
command, data = shared.workerQueue.get()
|
command, data = shared.workerQueue.get()
|
||||||
|
|
|
@ -396,6 +396,9 @@ def doCleanShutdown():
|
||||||
shutdown = 1 #Used to tell proof of work worker threads and the objectProcessorThread to exit.
|
shutdown = 1 #Used to tell proof of work worker threads and the objectProcessorThread to exit.
|
||||||
broadcastToSendDataQueues((0, 'shutdown', 'no data'))
|
broadcastToSendDataQueues((0, 'shutdown', 'no data'))
|
||||||
objectProcessorQueue.put(('checkShutdownVariable', 'no data'))
|
objectProcessorQueue.put(('checkShutdownVariable', 'no data'))
|
||||||
|
for thread in threading.enumerate():
|
||||||
|
if thread.isAlive() and isinstance(thread, StoppableThread):
|
||||||
|
thread.stopThread()
|
||||||
|
|
||||||
knownNodesLock.acquire()
|
knownNodesLock.acquire()
|
||||||
UISignalQueue.put(('updateStatusBar','Saving the knownNodes list of peers to disk...'))
|
UISignalQueue.put(('updateStatusBar','Saving the knownNodes list of peers to disk...'))
|
||||||
|
@ -430,9 +433,6 @@ def doCleanShutdown():
|
||||||
time.sleep(.25)
|
time.sleep(.25)
|
||||||
|
|
||||||
from class_outgoingSynSender import outgoingSynSender
|
from class_outgoingSynSender import outgoingSynSender
|
||||||
for thread in threading.enumerate():
|
|
||||||
if thread.isAlive() and isinstance(thread, StoppableThread):
|
|
||||||
thread.stopThread()
|
|
||||||
for thread in threading.enumerate():
|
for thread in threading.enumerate():
|
||||||
if thread is not threading.currentThread() and isinstance(thread, StoppableThread) and not isinstance(thread, outgoingSynSender):
|
if thread is not threading.currentThread() and isinstance(thread, StoppableThread) and not isinstance(thread, outgoingSynSender):
|
||||||
logger.debug("Waiting for thread %s", thread.name)
|
logger.debug("Waiting for thread %s", thread.name)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user