class_docstr: A file like object that publishes the stream to a 0MQ PUB socket.
  
  Output is handed off to an IO Thread
class_docstr_tok: ["A","file","like","object","that","publishes","the","stream","to","a","0MQ","PUB","socket",".","Output","is","handed","off","to","an","IO","Thread"]
docstr: This is where the actual send happens.
  
  _flush should generally be called in the IO thread,
  unless the thread has been destroyed (e.g. forked subprocess).
code: def _flush(self):
      """This is where the actual send happens.
  
      _flush should generally be called in the IO thread,
      unless the thread has been destroyed (e.g. forked subprocess).
      """
      self._flush_pending = False
      self._subprocess_flush_pending = False
  
      if self.echo is not None:
          try:
              self.echo.flush()
          except OSError as e:
              if self.echo is not sys.__stderr__:
                  print(f"Flush failed: {e}", file=sys.__stderr__)
  
      data = self._flush_buffer()
      if data:
          # FIXME: this disables Session's fork-safe check,
          # since pub_thread is itself fork-safe.
          # There should be a better way to do this.
          self.session.pid = os.getpid()
          content = {"name": self.name, "text": data}
          msg = self.session.msg(
              "stream", content, parent=self.parent_header
          )
  
          # Each transform either returns a new
          # message or None. If None is returned,
          # the message has been 'used' and we return.
          for hook in self._hooks:
              msg = hook(msg)
              if msg is None:
                  return
  
          self.session.send(
              self.pub_thread,
              msg,
              ident=self.topic,
          )
  
imports: import asyncio
  import atexit
  import io
  import os
  import sys
  import threading
  import traceback
  import warnings
  from binascii import b2a_hex
  from collections import deque
  from io import StringIO, TextIOBase
  from threading import local
  from typing import Any, Callable, Deque, Dict, Optional
  import zmq
  from jupyter_client.session import extract_header
  from tornado.ioloop import IOLoop
  from zmq.eventloop.zmqstream import ZMQStream
label_desc: Use image node_id 12 for calling the OutStream obj's underlying member method code with example usage: obj._flush() without return types