Skip to content

Commit 5f87415

Browse files
author
Jonathan Warren
committed
Merge pull request #281 from pgimeno/cpu100percentfix
Better fix for issue #183
2 parents b4e292e + 55b899f commit 5f87415

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/class_receiveDataThread.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@ def run(self):
6565
print 'ID of the receiveDataThread is', str(id(self)) + '. The size of the shared.connectedHostsList is now', len(shared.connectedHostsList)
6666
shared.printLock.release()
6767
while True:
68+
dataLen = len(self.data)
6869
try:
69-
dataLen = len(self.data)
7070
self.data += self.sock.recv(4096)
71-
if len(self.data) == dataLen: # recv returns 0 bytes when the remote closes the connection
72-
raise Exception("Remote closed the connection")
7371
except socket.timeout:
7472
shared.printLock.acquire()
7573
print 'Timeout occurred waiting for data from', self.HOST + '. Closing receiveData thread. (ID:', str(id(self)) + ')'
@@ -81,7 +79,7 @@ def run(self):
8179
shared.printLock.release()
8280
break
8381
# print 'Received', repr(self.data)
84-
if self.data == "":
82+
if len(self.data) == dataLen:
8583
shared.printLock.acquire()
8684
print 'Connection to', self.HOST, 'closed. Closing receiveData thread. (ID:', str(id(self)) + ')'
8785
shared.printLock.release()

0 commit comments

Comments
 (0)