Merge pull request #155 from Atheros1/master

Small changes to prevent or diagnose errors
This commit is contained in:
Jonathan Warren 2013-05-16 10:15:56 -07:00
commit 0bc95fe394
3 changed files with 35 additions and 13 deletions

View File

@ -2051,8 +2051,11 @@ class sendDataThread(threading.Thread):
shared.printLock.acquire() shared.printLock.acquire()
print 'sendDataThread (associated with', self.HOST,') ID:',id(self), 'shutting down now.' print 'sendDataThread (associated with', self.HOST,') ID:',id(self), 'shutting down now.'
shared.printLock.release() shared.printLock.release()
try:
self.sock.shutdown(socket.SHUT_RDWR) self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close() self.sock.close()
except:
pass
shared.sendDataQueues.remove(self.mailbox) shared.sendDataQueues.remove(self.mailbox)
shared.printLock.acquire() shared.printLock.acquire()
print 'len of sendDataQueues', len(shared.sendDataQueues) print 'len of sendDataQueues', len(shared.sendDataQueues)
@ -2087,8 +2090,11 @@ class sendDataThread(threading.Thread):
self.lastTimeISentData = int(time.time()) self.lastTimeISentData = int(time.time())
except: except:
print 'self.sock.sendall failed' print 'self.sock.sendall failed'
try:
self.sock.shutdown(socket.SHUT_RDWR) self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close() self.sock.close()
except:
pass
shared.sendDataQueues.remove(self.mailbox) shared.sendDataQueues.remove(self.mailbox)
print 'sendDataThread thread (ID:',str(id(self))+') ending now. Was connected to', self.HOST print 'sendDataThread thread (ID:',str(id(self))+') ending now. Was connected to', self.HOST
break break
@ -2107,8 +2113,11 @@ class sendDataThread(threading.Thread):
self.lastTimeISentData = int(time.time()) self.lastTimeISentData = int(time.time())
except: except:
print 'self.sock.sendall failed' print 'self.sock.sendall failed'
try:
self.sock.shutdown(socket.SHUT_RDWR) self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close() self.sock.close()
except:
pass
shared.sendDataQueues.remove(self.mailbox) shared.sendDataQueues.remove(self.mailbox)
print 'sendDataThread thread (ID:',str(id(self))+') ending now. Was connected to', self.HOST print 'sendDataThread thread (ID:',str(id(self))+') ending now. Was connected to', self.HOST
break break
@ -2123,8 +2132,11 @@ class sendDataThread(threading.Thread):
self.lastTimeISentData = int(time.time()) self.lastTimeISentData = int(time.time())
except: except:
print 'send pong failed' print 'send pong failed'
try:
self.sock.shutdown(socket.SHUT_RDWR) self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close() self.sock.close()
except:
pass
shared.sendDataQueues.remove(self.mailbox) shared.sendDataQueues.remove(self.mailbox)
print 'sendDataThread thread', self, 'ending now. Was connected to', self.HOST print 'sendDataThread thread', self, 'ending now. Was connected to', self.HOST
break break
@ -2446,7 +2458,15 @@ class sqlThread(threading.Thread):
parameters = shared.sqlSubmitQueue.get() parameters = shared.sqlSubmitQueue.get()
#print 'item', item #print 'item', item
#print 'parameters', parameters #print 'parameters', parameters
try:
self.cur.execute(item, parameters) self.cur.execute(item, parameters)
except Exception, err:
shared.printLock.acquire()
sys.stderr.write('\nMajor error occurred when trying to execute a SQL statement within the sqlThread. Please tell Atheros about this error message or post it in the forum! Error occurred while trying to execute statement: "'+str(item) + '" Here are the parameters; you might want to censor this data with asterisks (***) as it can contain private information: '+str(repr(parameters))+'\nHere is the actual error message thrown by the sqlThread: '+ str(err)+'\n')
sys.stderr.write('This program shall now abruptly exit!\n')
shared.printLock.release()
os._exit(0)
shared.sqlReturnQueue.put(self.cur.fetchall()) shared.sqlReturnQueue.put(self.cur.fetchall())
#shared.sqlSubmitQueue.task_done() #shared.sqlSubmitQueue.task_done()

View File

@ -230,9 +230,6 @@ class MyForm(QtGui.QMainWindow):
if isEnabled: if isEnabled:
status,addressVersionNumber,streamNumber,hash = decodeAddress(addressInKeysFile) status,addressVersionNumber,streamNumber,hash = decodeAddress(addressInKeysFile)
#self.sqlLookup = sqlThread()
#self.sqlLookup.start()
self.ui.tableWidgetSent.keyPressEvent = self.tableWidgetSentKeyPressEvent self.ui.tableWidgetSent.keyPressEvent = self.tableWidgetSentKeyPressEvent
font = QFont() font = QFont()
font.setBold(True) font.setBold(True)
@ -1744,7 +1741,9 @@ class MyForm(QtGui.QMainWindow):
self.ui.textEditInboxMessage.setText("") self.ui.textEditInboxMessage.setText("")
self.ui.tableWidgetInbox.removeRow(currentRow) self.ui.tableWidgetInbox.removeRow(currentRow)
self.statusBar().showMessage('Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.') self.statusBar().showMessage('Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.')
shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release()
if currentRow == 0: if currentRow == 0:
self.ui.tableWidgetInbox.selectRow(currentRow) self.ui.tableWidgetInbox.selectRow(currentRow)
else: else:
@ -1764,7 +1763,9 @@ class MyForm(QtGui.QMainWindow):
self.ui.textEditSentMessage.setPlainText("") self.ui.textEditSentMessage.setPlainText("")
self.ui.tableWidgetSent.removeRow(currentRow) self.ui.tableWidgetSent.removeRow(currentRow)
self.statusBar().showMessage('Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.') self.statusBar().showMessage('Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.')
shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release()
if currentRow == 0: if currentRow == 0:
self.ui.tableWidgetSent.selectRow(currentRow) self.ui.tableWidgetSent.selectRow(currentRow)
else: else:

View File

@ -167,11 +167,12 @@ def doCleanShutdown():
sqlSubmitQueue.put('SELECT address FROM subscriptions') sqlSubmitQueue.put('SELECT address FROM subscriptions')
sqlSubmitQueue.put('') sqlSubmitQueue.put('')
sqlReturnQueue.get() sqlReturnQueue.get()
sqlSubmitQueue.put('exit')
sqlLock.release() sqlLock.release()
printLock.acquire() printLock.acquire()
print 'Finished flushing inventory.' print 'Finished flushing inventory.'
printLock.release() printLock.release()
sqlSubmitQueue.put('exit')
if safeConfigGetBoolean('bitmessagesettings','daemon'): if safeConfigGetBoolean('bitmessagesettings','daemon'):
printLock.acquire() printLock.acquire()