Shutdown procedure cleanup
This commit is contained in:
parent
ca8550a206
commit
9ed59dd825
|
@ -636,6 +636,9 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
# switch back to this when replying
|
# switch back to this when replying
|
||||||
self.replyFromTab = None
|
self.replyFromTab = None
|
||||||
|
|
||||||
|
# so that quit won't loop
|
||||||
|
self.quitAccepted = False
|
||||||
|
|
||||||
self.init_file_menu()
|
self.init_file_menu()
|
||||||
self.init_inbox_popup_menu()
|
self.init_inbox_popup_menu()
|
||||||
|
@ -2693,6 +2696,9 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
return
|
return
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
if self.quitAccepted:
|
||||||
|
return
|
||||||
|
|
||||||
self.show()
|
self.show()
|
||||||
self.raise_()
|
self.raise_()
|
||||||
self.activateWindow()
|
self.activateWindow()
|
||||||
|
@ -2734,6 +2740,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
elif reply == QtGui.QMessageBox.Cancel:
|
elif reply == QtGui.QMessageBox.Cancel:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.quitAccepted = True
|
||||||
|
|
||||||
self.statusBar().showMessage(_translate(
|
self.statusBar().showMessage(_translate(
|
||||||
"MainWindow", "Shutting down PyBitmessage... %1%").arg(str(0)))
|
"MainWindow", "Shutting down PyBitmessage... %1%").arg(str(0)))
|
||||||
|
|
||||||
|
@ -2813,6 +2821,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.statusBar().showMessage(_translate("MainWindow", "Shutdown imminent... %1%").arg(str(100)))
|
self.statusBar().showMessage(_translate("MainWindow", "Shutdown imminent... %1%").arg(str(100)))
|
||||||
shared.thisapp.cleanup()
|
shared.thisapp.cleanup()
|
||||||
logger.info("Shutdown complete")
|
logger.info("Shutdown complete")
|
||||||
|
super(MyForm, myapp).close()
|
||||||
|
#return
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
# window close event
|
# window close event
|
||||||
|
@ -2827,6 +2837,10 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# always ignore, it shuts down by itself
|
# always ignore, it shuts down by itself
|
||||||
|
if self.quitAccepted:
|
||||||
|
event.accept()
|
||||||
|
return
|
||||||
|
|
||||||
event.ignore()
|
event.ignore()
|
||||||
if not trayonclose:
|
if not trayonclose:
|
||||||
# quit the application
|
# quit the application
|
||||||
|
|
|
@ -44,7 +44,7 @@ class outgoingSynSender(threading.Thread, StoppableThread):
|
||||||
peer, = random.sample(shared.knownNodes[self.streamNumber], 1)
|
peer, = random.sample(shared.knownNodes[self.streamNumber], 1)
|
||||||
except ValueError: # no known nodes
|
except ValueError: # no known nodes
|
||||||
shared.knownNodesLock.release()
|
shared.knownNodesLock.release()
|
||||||
time.sleep(1)
|
self.stop.wait(1)
|
||||||
continue
|
continue
|
||||||
priority = (183600 - (time.time() - shared.knownNodes[self.streamNumber][peer])) / 183600 # 2 days and 3 hours
|
priority = (183600 - (time.time() - shared.knownNodes[self.streamNumber][peer])) / 183600 # 2 days and 3 hours
|
||||||
shared.knownNodesLock.release()
|
shared.knownNodesLock.release()
|
||||||
|
@ -61,7 +61,7 @@ class outgoingSynSender(threading.Thread, StoppableThread):
|
||||||
priority = 0.001
|
priority = 0.001
|
||||||
if (random.random() <= priority):
|
if (random.random() <= priority):
|
||||||
break
|
break
|
||||||
time.sleep(0.01) # prevent CPU hogging if something is broken
|
self.stop.wait(0.01) # prevent CPU hogging if something is broken
|
||||||
try:
|
try:
|
||||||
return peer
|
return peer
|
||||||
except NameError:
|
except NameError:
|
||||||
|
@ -190,6 +190,10 @@ class outgoingSynSender(threading.Thread, StoppableThread):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.sock.connect((peer.host, peer.port))
|
self.sock.connect((peer.host, peer.port))
|
||||||
|
if self._stopped:
|
||||||
|
self.sock.shutdown(socket.SHUT_RDWR)
|
||||||
|
self.sock.close()
|
||||||
|
return
|
||||||
someObjectsOfWhichThisRemoteNodeIsAlreadyAware = {} # This is not necessairly a complete list; we clear it from time to time to save memory.
|
someObjectsOfWhichThisRemoteNodeIsAlreadyAware = {} # This is not necessairly a complete list; we clear it from time to time to save memory.
|
||||||
sendDataThreadQueue = Queue.Queue(100) # Used to submit information to the send data thread for this connection.
|
sendDataThreadQueue = Queue.Queue(100) # Used to submit information to the send data thread for this connection.
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ class sendDataThread(threading.Thread):
|
||||||
state.sendDataQueues.append(self.sendDataThreadQueue)
|
state.sendDataQueues.append(self.sendDataThreadQueue)
|
||||||
self.data = ''
|
self.data = ''
|
||||||
self.objectHashHolderInstance = objectHashHolder(self.sendDataThreadQueue)
|
self.objectHashHolderInstance = objectHashHolder(self.sendDataThreadQueue)
|
||||||
|
self.objectHashHolderInstance.daemon = True
|
||||||
self.objectHashHolderInstance.start()
|
self.objectHashHolderInstance.start()
|
||||||
self.connectionIsOrWasFullyEstablished = False
|
self.connectionIsOrWasFullyEstablished = False
|
||||||
|
|
||||||
|
@ -83,6 +84,8 @@ class sendDataThread(threading.Thread):
|
||||||
amountSent = self.sslSock.send(self.buffer[:throttle.SendThrottle().chunkSize])
|
amountSent = self.sslSock.send(self.buffer[:throttle.SendThrottle().chunkSize])
|
||||||
else:
|
else:
|
||||||
amountSent = self.sock.send(self.buffer[:throttle.SendThrottle().chunkSize])
|
amountSent = self.sock.send(self.buffer[:throttle.SendThrottle().chunkSize])
|
||||||
|
except socket.timeout:
|
||||||
|
continue
|
||||||
except socket.error as e:
|
except socket.error as e:
|
||||||
if e.errno == errno.EAGAIN:
|
if e.errno == errno.EAGAIN:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -234,12 +234,23 @@ def doCleanShutdown():
|
||||||
logger.debug("Waiting for thread %s", thread.name)
|
logger.debug("Waiting for thread %s", thread.name)
|
||||||
thread.join()
|
thread.join()
|
||||||
|
|
||||||
|
# flush queued
|
||||||
|
for queue in (workerQueue, UISignalQueue, addressGeneratorQueue, objectProcessorQueue):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
queue.get(False)
|
||||||
|
queue.task_done()
|
||||||
|
except Queue.Empty:
|
||||||
|
break
|
||||||
|
|
||||||
if BMConfigParser().safeGetBoolean('bitmessagesettings','daemon'):
|
if BMConfigParser().safeGetBoolean('bitmessagesettings','daemon'):
|
||||||
logger.info('Clean shutdown complete.')
|
logger.info('Clean shutdown complete.')
|
||||||
thisapp.cleanup()
|
thisapp.cleanup()
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
else:
|
else:
|
||||||
logger.info('Core shutdown complete.')
|
logger.info('Core shutdown complete.')
|
||||||
|
for thread in threading.enumerate():
|
||||||
|
logger.debug("Thread %s still running", thread.name)
|
||||||
|
|
||||||
def fixPotentiallyInvalidUTF8Data(text):
|
def fixPotentiallyInvalidUTF8Data(text):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user