Bail out correctly if socket.recv gets nothing (indicating a closed socket)

This commit is contained in:
James Cammarata 2013-08-19 09:59:47 -05:00
parent 3d3b318a86
commit e92df1dc76

View file

@ -163,7 +163,10 @@ class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):
data_len = struct.unpack('Q',data[:header_len])[0]
data = data[header_len:]
while len(data) < data_len:
data += self.request.recv(1024)
d = self.request.recv(1024)
if not d:
return None
data += d
return data
def handle(self):