class_docstr: An object for sending IOPub messages in a background thread
  
  Prevents a blocking main thread from delaying output from threads.
  
  IOPubThread(pub_socket).background_socket is a Socket-API-providing object
  whose IO is always run in a thread.
class_docstr_tok: ["An","object","for","sending","IOPub","messages","in","a","background","thread","Prevents","a","blocking","main","thread","from","delaying","output","from","threads",".","IOPubThread","(","pub_socket",")",".background_socket","is","a","Socket-API-providing","object","whose","IO","is","always","run","in","a","thread","."]
docstr: The inner loop that's actually run in a thread
code: def _thread_main(self):
      """The inner loop that's actually run in a thread"""
  
      def _start_event_gc():
          self._event_pipe_gc_task = asyncio.ensure_future(
              self._run_event_pipe_gc()
          )
  
      self.io_loop.run_sync(_start_event_gc)
  
      if not self._stopped:
          # avoid race if stop called before start thread gets here
          # probably only comes up in tests
          self.io_loop.start()
  
      if self._event_pipe_gc_task is not None:
          # cancel gc task to avoid pending task warnings
          async def _cancel():
              self._event_pipe_gc_task.cancel()  # type:ignore[union-attr]
  
          if not self._stopped:
              self.io_loop.run_sync(_cancel)
          else:
              self._event_pipe_gc_task.cancel()
  
      self.io_loop.close(all_fds=True)
  
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 2 for calling the IOPubThread obj's underlying member method code with example usage: obj._thread_main() without return types