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","."]
code: def _write_thread(self) -> None:
      done = False
  
      while not done:
          item = self._flush_queue.get()
  
          if isinstance(item, _Done):
              break
  
          # Don't bother calling when we got an empty string.
          if not item:
              continue
  
          text = []
          text.append(item)
  
          # Read the rest of the queue if more data was queued up.
          while True:
              try:
                  item = self._flush_queue.get_nowait()
              except queue.Empty:
                  break
              else:
                  if isinstance(item, _Done):
                      done = True
                  else:
                      text.append(item)
  
          app_loop = self._get_app_loop()
          self._write_and_flush(app_loop, "".join(text))
  
          # If an application was running that requires repainting, then wait
          # for a very short time, in order to bundle actual writes and avoid
          # having to repaint to often.
          if app_loop is not None:
              time.sleep(self.sleep_between_writes)
  
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 6 for calling the StdoutProxy obj's underlying member method code with example usage: obj._write_thread() without return types