class_docstr: A client for an in-process kernel.
  
  This class implements the interface of
  `jupyter_client.clientabc.KernelClientABC` and allows
  (asynchronous) frontends to be used seamlessly with an in-process kernel.
  
  See `jupyter_client.client.KernelClient` for docstrings.
class_docstr_tok: ["A","client","for","an","in-process","kernel",".","This","class","implements","the","interface","of","`","jupyter_client.clientabc.KernelClientABC","`","and","allows","(","asynchronous",")","frontends","to","be","used","seamlessly","with","an","in-process","kernel",".","See","`","jupyter_client.client.KernelClient","`","for","docstrings","."]
docstr: Send a message to the kernel and handle a reply.
docstr_tok: ["Send","a","message","to","the","kernel","and","handle","a","reply","."]
code: def _dispatch_to_kernel(self, msg):
      """Send a message to the kernel and handle a reply."""
      kernel = self.kernel
      if kernel is None:
          msg = "Cannot send request. No kernel exists."
          raise RuntimeError(msg)
  
      stream = kernel.shell_stream
      self.session.send(stream, msg)
      msg_parts = stream.recv_multipart()
      if run_sync is not None:
          dispatch_shell = run_sync(kernel.dispatch_shell)
          dispatch_shell(msg_parts)
      else:
          loop = asyncio.get_event_loop()  # type:ignore[unreachable]
          loop.run_until_complete(kernel.dispatch_shell(msg_parts))
      idents, reply_msg = self.session.recv(stream, copy=False)
      self.shell_channel.call_handlers_later(reply_msg)
  
imports: import asyncio
  from jupyter_client.client import KernelClient
  from jupyter_client.clientabc import KernelClientABC
  from jupyter_core.utils import run_sync
  from traitlets import Instance, Type, default
  from .channels import InProcessChannel, InProcessHBChannel
label_desc: Use image node_id 18 for calling the InProcessKernelClient obj's underlying member method code with example usage: obj._dispatch_to_kernel(msg) without return types