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
d925ab61b3
commit
00e90bd38f
|
@ -71,18 +71,19 @@ class singleWorker(threading.Thread, StoppableThread):
|
|||
self.stop.wait(
|
||||
10) # give some time for the GUI to start before we start on existing POW tasks.
|
||||
|
||||
queryreturn = sqlQuery(
|
||||
'''SELECT DISTINCT toaddress FROM sent WHERE (status='doingpubkeypow' AND folder='sent')''')
|
||||
for row in queryreturn:
|
||||
toaddress, = row
|
||||
self.requestPubKey(toaddress)
|
||||
|
||||
self.sendMsg()
|
||||
# just in case there are any pending tasks for msg
|
||||
# messages that have yet to be sent.
|
||||
self.sendBroadcast()
|
||||
# just in case there are any tasks for Broadcasts
|
||||
# that have yet to be sent.
|
||||
if shared.shutdown == 0:
|
||||
queryreturn = sqlQuery(
|
||||
'''SELECT DISTINCT toaddress FROM sent WHERE (status='doingpubkeypow' AND folder='sent')''')
|
||||
for row in queryreturn:
|
||||
toaddress, = row
|
||||
logger.debug("c: %s", shared.shutdown)
|
||||
self.requestPubKey(toaddress)
|
||||
# just in case there are any pending tasks for msg
|
||||
# messages that have yet to be sent.
|
||||
self.sendMsg()
|
||||
# just in case there are any tasks for Broadcasts
|
||||
# that have yet to be sent.
|
||||
self.sendBroadcast()
|
||||
|
||||
while shared.shutdown == 0:
|
||||
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.
|
||||
broadcastToSendDataQueues((0, 'shutdown', 'no data'))
|
||||
objectProcessorQueue.put(('checkShutdownVariable', 'no data'))
|
||||
for thread in threading.enumerate():
|
||||
if thread.isAlive() and isinstance(thread, StoppableThread):
|
||||
thread.stopThread()
|
||||
|
||||
knownNodesLock.acquire()
|
||||
UISignalQueue.put(('updateStatusBar','Saving the knownNodes list of peers to disk...'))
|
||||
|
@ -430,9 +433,6 @@ def doCleanShutdown():
|
|||
time.sleep(.25)
|
||||
|
||||
from class_outgoingSynSender import outgoingSynSender
|
||||
for thread in threading.enumerate():
|
||||
if thread.isAlive() and isinstance(thread, StoppableThread):
|
||||
thread.stopThread()
|
||||
for thread in threading.enumerate():
|
||||
if thread is not threading.currentThread() and isinstance(thread, StoppableThread) and not isinstance(thread, outgoingSynSender):
|
||||
logger.debug("Waiting for thread %s", thread.name)
|
||||
|
|
Loading…
Reference in New Issue
Block a user