class_docstr: Object for monitoring
  
  Must be child of engine
  
  Handles signal messages and watches Engine process for exiting
class_docstr_tok: ["Object","for","monitoring","Must","be","child","of","engine","Handles","signal","messages","and","watches","Engine","process","for","exiting"]
docstr: Main body function.
  
  Instantiates and starts a nanny.
  
  Args and keyword args passed to the constructor.
  
  Should be called in a subprocess.
docstr_tok: ["Main","body","function",".","Instantiates","and","starts","a","nanny",".","Args","and","keyword","args","passed","to","the","constructor",".","Should","be","called","in","a","subprocess","."]
code: def main(cls, *args, **kwargs):
      """Main body function.
  
      Instantiates and starts a nanny.
  
      Args and keyword args passed to the constructor.
  
      Should be called in a subprocess.
      """
      self = cls(*args, **kwargs)
      asyncio_loop = asyncio.new_event_loop()
      asyncio_loop.run_until_complete(self.start())
      try:
          asyncio_loop.run_forever()
      finally:
          self.loop.close(all_fds=True)
          self.context.term()
          try:
              self.pipe.close()
          except BrokenPipeError:
              pass
          self.log.debug("exiting")
  
imports: import asyncio
  import logging
  import os
  import pickle
  import signal
  import sys
  from subprocess import PIPE, Popen
  from threading import Thread
  import psutil
  import zmq
  from jupyter_client.session import Session
  from tornado.ioloop import IOLoop
  from traitlets.config import Config
  from zmq.eventloop.zmqstream import ZMQStream
  from ipyparallel import error, util
  from ipyparallel.util import local_logger
label_desc: Use image node_id 9 for calling the KernelNanny obj's underlying member method code with example usage: obj.main(cls) without return types