def write(self, data, flush=False):
        """
        Write data to the channel.

        Data will not be written immediately, but will be buffered
        internally until it can be sent without blocking the process.

        Calling :meth:`write()` on a closed or disconnected channel will
        raise a :exc:`RuntimeError`.

        ==========  ===================================================
        Arguments   Description
        ==========  ===================================================
        data        A string of data to write to the channel.
        flush       *Optional.* If True, flush the internal write
                    buffer. See :meth:`~pants.stream.Stream.flush` for
                    details.
        ==========  ===================================================
        """
        if self._closed or self._closing:
            raise RuntimeError("write() called on closed %r." % self)

        if not self.connected:
            raise RuntimeError(self % "write() called on disconnected %r.")

        if self._send_buffer and self._send_buffer[-1][0] == Stream.SEND_STRING:
            data_type, existing_data = self._send_buffer.pop(-1)
            data = existing_data + data

        self._send_buffer.append((Stream.SEND_STRING, data))

        if flush:
            self._process_send_buffer()
        else:
            self._start_waiting_for_write_event()
dataset/ETHPy150Open ecdavis/pants/pants/stream.py/Stream.write/swapped operands of `%`