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: Dispatch message from the control scheduler
  
  If we have a handler registered
docstr_tok: ["Dispatch","message","from","the","control","scheduler","If","we","have","a","handler","registered"]
code: def dispatch_control(self, stream, raw_msg):
      """Dispatch message from the control scheduler
  
      If we have a handler registered"""
      try:
          idents, msg_frames = self.session.feed_identities(raw_msg)
      except Exception as e:
          self.log.error(
              f"Bad control message: {raw_msg}", exc_info=True
          )
          return
  
      try:
          msg = self.session.deserialize(msg_frames, content=True)
      except Exception:
          content = error.wrap_exception()
          self.log.error(
              "Bad control message: %r", msg_frames, exc_info=True
          )
          return
  
      msg_type = msg["header"]["msg_type"]
      if msg_type.endswith("_request"):
          reply_type = msg_type[-len("_request") :]
      else:
          reply_type = "error"
      self.log.debug(f"Client {idents[-1]} requested {msg_type}")
  
      handler = self.control_handlers.get(msg_type, None)
      if handler is None:
          # don't have an intercept handler, relay original message to parent
          self.log.debug(
              f"Relaying {msg_type} {msg['header']['msg_id']}"
          )
          self.parent_stream.send_multipart(raw_msg)
          return
  
      try:
          content = handler(msg["content"])
      except Exception:
          content = error.wrap_exception()
          self.log.error(
              "Error handling request: %r", msg_type, exc_info=True
          )
  
      self.session.send(
          stream, reply_type, ident=idents, content=content, parent=msg
      )
  
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 6 for calling the KernelNanny obj's underlying member method code with example usage: obj.dispatch_control(stream, raw_msg) without return types