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: Write to current stream after encoding if necessary
  
  Returns
  -------
  len : int
      number of items from input parameter written to stream.
code: def write(
      self, string: str
  ) -> Optional[int]:  # type:ignore[override]
      """Write to current stream after encoding if necessary
  
      Returns
      -------
      len : int
          number of items from input parameter written to stream.
  
      """
  
      if not isinstance(string, str):
          msg = (
              f"write() argument must be str, not {type(string)}"
          )  # type:ignore[unreachable]
          raise TypeError(msg)
  
      if self.echo is not None:
          try:
              self.echo.write(string)
          except OSError as e:
              if self.echo is not sys.__stderr__:
                  print(f"Write failed: {e}", file=sys.__stderr__)
  
      if self.pub_thread is None:
          msg = "I/O operation on closed file"
          raise ValueError(msg)
  
      is_child = not self._is_master_process()
      # only touch the buffer in the IO thread to avoid races
      with self._buffer_lock:
          self._buffer.write(string)
      if is_child:
          # mp.Pool cannot be trusted to flush promptly (or ever),
          # and this helps.
          if self._subprocess_flush_pending:
              return None
          self._subprocess_flush_pending = True
          # We can not rely on self._io_loop.call_later from a subprocess
          self.pub_thread.schedule(self._flush)
      else:
          self._schedule_flush()
  
      return len(string)
  
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 13 for calling the OutStream obj's underlying member method code with example usage: obj.write(string) and returns: len, None