def write(self, data):
        """
        Write `data` to the Stream. Not all data may be written right away.
        Use select to find when the stream is writeable, and call do_write()
        to flush the internal buffer.
        """

        if not data:
            return None

        self.buffer += data
        self.do_write()

        return len(data)