Writes a batch of `size` lines to `buff`.

    Returns boolean of whether the stream has been exhausted.
767086
def batch_stream(buff, stream, size=DEFAULT_BATCH_SIZE):
    
    buff.truncate(0)
    for _ in xrange(size):
        if hasattr(stream, 'readline'):
            line = stream.readline()
        else:
            try:
                line = next(stream)
            except StopIteration:
                line = ''

        # No more lines, return the tmp
        if line == '':
            buff.seek(0)
            return True
        buff.write(line)
    buff.seek(0)
    return False
1117961
public final void fillWriteBuffer(boolean shouldOptimize) {
    if (toWrite == 0 && readQ.remainingCapacity() > 0) {
      getWbuf().clear();
      Operation o=getNextWritableOp();

      while(o != null && toWrite < getWbuf().capacity()) {
        synchronized(o) {
          assert o.getState() == OperationState.WRITING;

          ByteBuffer obuf = o.getBuffer();
          assert obuf != null : "Didn't get a write buffer from " + o;
          int bytesToCopy = Math.min(getWbuf().remaining(), obuf.remaining());
          byte[] b = new byte[bytesToCopy];
          obuf.get(b);
          getWbuf().put(b);
          getLogger().debug("After copying stuff from %s: %s", o, getWbuf());
          if (!o.getBuffer().hasRemaining()) {
            o.writeComplete();
            transitionWriteItem();

            preparePending();
            if (shouldOptimize) {
              optimize();
            }

            o=getNextWritableOp();
          }
          toWrite += bytesToCopy;
        }
      }
      getWbuf().flip();
      assert toWrite <= getWbuf().capacity() : "toWrite exceeded capacity: "
          + this;
      assert toWrite == getWbuf().remaining() : "Expected " + toWrite
          + " remaining, got " + getWbuf().remaining();
    } else {
      getLogger().debug("Buffer is full, skipping");
    }
  }
390117
def write(self, data):
        
        if self.closed:
            raise ConnectionResetError(
                'Transport closed - cannot write on %s' % self
            )
        else:
            t = self.transport
            if self._paused or self._buffer:
                self._buffer.appendleft(data)
                self._buffer_size += len(data)
                self._write_from_buffer()
                if self._buffer_size > 2 * self._b_limit:
                    if self._waiter and not self._waiter.cancelled():
                        self.logger.warning(
                            '%s buffer size is %d: limit is %d ',
                            self._buffer_size, self._b_limit
                        )
                    else:
                        t.pause_reading()
                        self._waiter = self._loop.create_future()
            else:
                t.write(data)
            self.changed()
            return self._waiter
1157734
def dump_stream(self, iterator, stream):
        
        batches = (self._create_batch(series) for series in iterator)
        super(ArrowStreamPandasSerializer, self).dump_stream(batches, stream)
510217
def write(self, string, *args, **kwargs):
        
        if self.on_new_line:
            self.on_new_line = False  # We're not on a new line anymore
            # If the string was not empty, indent; Else probably a new line
            if string.strip():
                self.indent()

        if args or kwargs:
            self.out_stream.write(string.format(*args, **kwargs))
        else:
            self.out_stream.write(string)
966463
def write(self, s, flush=True):
        
        return self._writeb(s, flush=flush)
205502
def _unbuffered(self, proc, stream='stdout'):
        
        if self.working_handler is not None:
            t = Thread(target=self._handle_process, args=(proc, stream))
            t.start()
        out = getattr(proc, stream)
        try:
            for line in iter(out.readline, ""):
                yield line.rstrip()
        finally:
            out.close()
1321106
def bulk_write(self, requests, **kwargs):
        
        self._arctic_lib.check_quota()
        return self._collection.bulk_write(requests, **kwargs)
922176
def write(self, msg, style_func=None, ending=None, stream=None):
        
        if stream is None:
            stream = self.stdout
        if OutputWrapper is None:
            ending = "\n" if ending is None else ending
            msg += ending
            stream.write(msg)
        else:
            stream.write(msg, style_func=style_func, ending=ending)
598556
function on_write (metric, enc, done) {
  var name = metric.name
  var values = metric.values
  var tags = metric.tags

  locals.batch.list[name] = locals.batch.list[name] || []
  locals.batch.list[name].push([values, tags])
  locals.batch.count = locals.batch.count + 1

  var exceeded = locals.batch.count >= locals.batch.max
  var expired = Date.now() > locals.batch.next

  if (exceeded || expired) {
    write_batch()
  }

  done()
}
496774
def closeStreamToFile(self) :
		""""""
		if self.streamBuffer is None :
			raise ValueError("Commit lines is only for when you are streaming to a file")

		for i in xrange(len(self.streamBuffer)) :
			self.streamBuffer[i] = str(self.streamBuffer[i])
		self.streamFile.write('\n'.join(self.streamBuffer))
		self.streamFile.close()

		self.streamFile = None
		self.writeRate = None
		self.streamBuffer = None
		self.keepInMemory = True
1226453
def on_batch_end(self, last_loss:Tensor, iteration:int, **kwargs)->None:
        ""
        if iteration == 0: return
        self._update_batches_if_needed()
        if iteration % self.loss_iters == 0: self._write_training_loss(iteration=iteration, last_loss=last_loss)
        if iteration % self.hist_iters == 0: self._write_weight_histograms(iteration=iteration)
699097
function writeLines() {
    var chunk = lines.slice(i * size, (i * size) + size);

    // all done
    if(!chunk.length) {
      return encoder.end();
    }

    // ensure we get correct line break between
    // line chunks, the encoder joins lines on EOL
    // this means that the last line in the chunk array
    // does not have an EOL, we need to ensure it does
    if(i > 0) {
      chunk.unshift('');
    }

    // write out the line chunk
    encoder.write(chunk);
    setImmediate(writeLines);
    i++;
  }
384116
def write(self, *args, **kwargs):
        
        return self.stream.write(ending="", *args, **kwargs)
954274
private static void __flush(InputStream is, OutputStream os, int bufferSize) throws IOException {
        byte[] buffer = new byte[bufferSize];

        for (int length = 0; (length = is.read(buffer)) > 0;) {
            os.write(buffer, 0, length);
        }
    }
1011587
def eof?
      fail IOError, "closed stream" if closed?

      return false if cache && !cache.eof?
      @buffer.nil? && chunks_depleted?
    end
701797
function (list) {
            var batch_size = 100,
                cutoff;

            if (list.length >= batch_size) {
                // If we have more clients than our batch size, call ourself with the next batch
                setTimeout(function () {
                    sendCommandBatch(list.slice(batch_size));
                }, 200);

                cutoff = batch_size;

            } else {
                cutoff = list.length;
            }

            list.slice(0, cutoff).forEach(function (client) {
                if (!client.disposed) {
                    client.sendKiwiCommand(command, data);
                }
            });

            if (cutoff === list.length && typeof callback === 'function') {
                callback();
            }
        }