'Drain \'n\' bytes from the buffer.
If \'n\' is negative, drain the whole buffer.
If \'n\' is larger than the size of the buffer, drain the whole
buffer.'

def drain(self, n=(-1)):

    with self.data_lock:
        if ((n < 0) or (n > len(self.buffer))):
            self.buffer = bytes('')
            return
        self.buffer = self.buffer[n:]
        return
