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"]
code: def __init__(self, session, pub_thread, name, pipe=None, echo=None):
      if pipe is not None:
          warnings.warn(
              "pipe argument to OutStream is deprecated and ignored",
              DeprecationWarning,
          )
      # This is necessary for compatibility with Python built-in streams
      self.session = session
      if not isinstance(pub_thread, IOPubThread):
          # Backward-compat: given socket, not thread. Wrap in a thread.
          warnings.warn(
              "OutStream should be created with IOPubThread, not %r"
              % pub_thread,
              DeprecationWarning,
              stacklevel=2,
          )
          pub_thread = IOPubThread(pub_thread)
          pub_thread.start()
      self.pub_thread = pub_thread
      self.name = name
      self.topic = b"stream." + py3compat.cast_bytes(name)
      self.parent_header = {}
      self._master_pid = os.getpid()
      self._flush_pending = False
      self._io_loop = pub_thread.io_loop
      self._new_buffer()
      self.echo = None
  
      if echo:
          if hasattr(echo, "read") and hasattr(echo, "write"):
              self.echo = echo
          else:
              raise ValueError(
                  "echo argument must be a file like object"
              )
  
imports: from __future__ import print_function
  import atexit
  from binascii import b2a_hex
  from collections import deque
  import os
  import sys
  import threading
  import warnings
  from io import StringIO, TextIOBase
  import zmq
  from zmq.eventloop.ioloop import IOLoop
  from zmq.eventloop.zmqstream import ZMQStream
  from jupyter_client.session import extract_header
  from ipython_genutils import py3compat
  from ipython_genutils.py3compat import unicode_type
label_desc: Use image node_id 1 to create a new OutStream object from inherited base classes: TextIOBase with example: obj = OutStream(session, pub_thread, name, pipe, echo)