In the read() member function the loop is such that is looses data.
If the data length requested is more than 1, then unless the data is immediately available (i.e. the loop runs no more than one time)
then the first and subsequent read data is deleted.
Also, socket.recv() returns a string, so using a bytearray is pointless.
Required changes shown below:
#data = bytearray()
data = ""
#data = self._socket.recv(size - len(data))
data += self._socket.recv(size - len(data))