'Recv logic with interruptions'

def recv(self):

    packet = self.stream.read(self.FRAME_HEADER.size)
    if (not packet):
        return None
    header = packet
    while (len(header) != self.FRAME_HEADER.size):
        packet = self.stream.read((self.FRAME_HEADER.size - len(header)))
        if packet:
            header += packet
    (length, compressed) = self.FRAME_HEADER.unpack(header)
    data = ''
    required_length = (length + len(self.FLUSHER))
    while (len(data) != required_length):
        packet = self.stream.read((required_length - len(data)))
        if packet:
            data += packet
    data = data[:(- len(self.FLUSHER))]
    if compressed:
        data = zlib.decompress(data)
    return data
