added extra statements for troubleshooting

This commit is contained in:
Jonathan Warren 2013-04-30 10:54:30 -04:00
parent 8e042930f2
commit 0b78e36639

View File

@ -260,25 +260,25 @@ class receiveDataThread(QThread):
def run(self): def run(self):
printLock.acquire() printLock.acquire()
print 'The size of the connectedHostsList is now', len(connectedHostsList) print 'ID of the receiveDataThread is', str(id(self))+'. The size of the connectedHostsList is now', len(connectedHostsList)
printLock.release() printLock.release()
while True: while True:
try: try:
self.data += self.sock.recv(4096) self.data += self.sock.recv(4096)
except socket.timeout: except socket.timeout:
printLock.acquire() printLock.acquire()
print 'Timeout occurred waiting for data. Closing receiveData thread.' print 'Timeout occurred waiting for data from', self.HOST + '. Closing receiveData thread. (ID:',str(id(self))+ ')'
printLock.release() printLock.release()
break break
except Exception, err: except Exception, err:
printLock.acquire() printLock.acquire()
print 'sock.recv error. Closing receiveData thread.', err print 'sock.recv error. Closing receiveData thread (HOST:', self.HOST, 'ID:',str(id(self))+ ').', err
printLock.release() printLock.release()
break break
#print 'Received', repr(self.data) #print 'Received', repr(self.data)
if self.data == "": if self.data == "":
printLock.acquire() printLock.acquire()
print 'Connection closed. Closing receiveData thread.' print 'Connection to', self.HOST, 'closed. Closing receiveData thread. (ID:',str(id(self))+ ')'
printLock.release() printLock.release()
break break
else: else:
@ -2003,7 +2003,7 @@ class sendDataThread(QThread):
self.lastTimeISentData = int(time.time()) #If this value increases beyond five minutes ago, we'll send a pong message to keep the connection alive. self.lastTimeISentData = int(time.time()) #If this value increases beyond five minutes ago, we'll send a pong message to keep the connection alive.
self.objectsOfWhichThisRemoteNodeIsAlreadyAware = objectsOfWhichThisRemoteNodeIsAlreadyAware self.objectsOfWhichThisRemoteNodeIsAlreadyAware = objectsOfWhichThisRemoteNodeIsAlreadyAware
printLock.acquire() printLock.acquire()
print 'The streamNumber of this sendDataThread (ID:', id(self),') at setup() is', self.streamNumber print 'The streamNumber of this sendDataThread (ID:', str(id(self))+') at setup() is', self.streamNumber
printLock.release() printLock.release()
def sendVersionMessage(self): def sendVersionMessage(self):
@ -2068,7 +2068,7 @@ class sendDataThread(QThread):
self.sock.shutdown(socket.SHUT_RDWR) self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close() self.sock.close()
sendDataQueues.remove(self.mailbox) sendDataQueues.remove(self.mailbox)
print 'sendDataThread thread', self, 'ending now' print 'sendDataThread thread (ID:',str(id(self))+') ending now. Was connected to', self.HOST
break break
elif command == 'sendinv': elif command == 'sendinv':
if data not in self.objectsOfWhichThisRemoteNodeIsAlreadyAware: if data not in self.objectsOfWhichThisRemoteNodeIsAlreadyAware:
@ -2088,7 +2088,7 @@ class sendDataThread(QThread):
self.sock.shutdown(socket.SHUT_RDWR) self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close() self.sock.close()
sendDataQueues.remove(self.mailbox) sendDataQueues.remove(self.mailbox)
print 'sendDataThread thread', self, 'ending now' print 'sendDataThread thread (ID:',str(id(self))+') ending now. Was connected to', self.HOST
break break
elif command == 'pong': elif command == 'pong':
if self.lastTimeISentData < (int(time.time()) - 298): if self.lastTimeISentData < (int(time.time()) - 298):
@ -2100,11 +2100,11 @@ class sendDataThread(QThread):
self.sock.sendall('\xE9\xBE\xB4\xD9\x70\x6F\x6E\x67\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xcf\x83\xe1\x35') self.sock.sendall('\xE9\xBE\xB4\xD9\x70\x6F\x6E\x67\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xcf\x83\xe1\x35')
self.lastTimeISentData = int(time.time()) self.lastTimeISentData = int(time.time())
except: except:
print 'self.sock.send pong failed' print 'send pong failed'
self.sock.shutdown(socket.SHUT_RDWR) self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close() self.sock.close()
sendDataQueues.remove(self.mailbox) sendDataQueues.remove(self.mailbox)
print 'sendDataThread thread', self, 'ending now' print 'sendDataThread thread', self, 'ending now. Was connected to', self.HOST
break break
else: else:
printLock.acquire() printLock.acquire()