def handle_write(self):
        """Write up to `maxdata` bytes to the pipe."""
        if self.writable():
            self.__offset += self.send(
                    self.__buffer[self.__offset:self.__offset+self.maxdata])
            # If the buffer is all written, empty it.
            if self.__offset >= len(self.__buffer):
                self.__buffer = None
                self.__offset = 0
                if self.__close_when_done: self.close()
Write up to `maxdata` bytes to the pipe.
recipes/Python/576967_Asynchronous_pipe_communicatiusing/recipe-576967.py