class_docstr: File-like object, which prints everything written to it, output above the
  current application/prompt. This class is compatible with other file
  objects and can be used as a drop-in replacement for `sys.stdout` or can
  for instance be passed to `logging.StreamHandler`.
  
  The current application, above which we print, is determined by looking
  what application currently runs in the `AppSession` that is active during
  the creation of this instance.
  
  This class can be used as a context manager.
  
  In order to avoid having to repaint the prompt continuously for every
  little write, a short delay of `sleep_between_writes` seconds will be added
  between writes in order to bundle many smaller writes in a short timespan.
class_docstr_tok: ["File-like","object",",","which","prints","everything","written","to","it",",","output","above","the","current","application\/prompt",".","This","class","is","compatible","with","other","file","objects","and","can","be","used","as","a","drop-in","replacement","for","`","sys.stdout","`","or","can","for","instance","be","passed","to","`","logging.StreamHandler","`",".","The","current","application",",","above","which","we","print",",","is","determined","by","looking","what","application","currently","runs","in","the","`","AppSession","`","that","is","active","during","the","creation","of","this","instance",".","This","class","can","be","used","as","a","context","manager",".","In","order","to","avoid","having","to","repaint","the","prompt","continuously","for","every","little","write",",","a","short","delay","of","`","sleep_between_writes","`","seconds","will","be","added","between","writes","in","order","to","bundle","many","smaller","writes","in","a","short","timespan","."]
docstr:         Note: print()-statements cause to multiple write calls.
                (write('line') and write('
  ')). Of course we don't want to call
                `run_in_terminal` for every individual call, because that's too
                expensive, and as long as the newline hasn't been written, the
                text itself is again overwritten by the rendering of the input
                command line. Therefor, we have a little buffer which holds the
                text until a newline is written to stdout.
          
docstr_tok: ["Note",":","print","(",")","-statements","cause","to","multiple","write","calls",".","(","write","(","'line","'",")","and","write","(","'","'",")",")",".","Of","course","we","do","n't","want","to","call","`","run_in_terminal","`","for","every","individual","call",",","because","that","'s","too","expensive",",","and","as","long","as","the","newline","has","n't","been","written",",","the","text","itself","is","again","overwritten","by","the","rendering","of","the","input","command","line",".","Therefor",",","we","have","a","little","buffer","which","holds","the","text","until","a","newline","is","written","to","stdout","."]
code: def _write(self, data: str) -> None:
      """
      Note: print()-statements cause to multiple write calls.
            (write('line') and write('\n')). Of course we don't want to call
            `run_in_terminal` for every individual call, because that's too
            expensive, and as long as the newline hasn't been written, the
            text itself is again overwritten by the rendering of the input
            command line. Therefor, we have a little buffer which holds the
            text until a newline is written to stdout.
      """
      if "\n" in data:
          # When there is a newline in the data, write everything before the
          # newline, including the newline itself.
          before, after = data.rsplit("\n", 1)
          to_write = self._buffer + [before, "\n"]
          self._buffer = [after]
  
          text = "".join(to_write)
          self._flush_queue.put(text)
      else:
          # Otherwise, cache in buffer.
          self._buffer.append(data)
  
imports: from __future__ import annotations
  import asyncio
  import queue
  import sys
  import threading
  import time
  from contextlib import contextmanager
  from typing import Generator, TextIO, cast
  from .application import get_app_session, run_in_terminal
  from .output import Output
label_desc: Use image node_id 9 for calling the StdoutProxy obj's underlying member method code with example usage: obj._write(data) without return types