class_docstr: Class for communicating between a Frontend and a Kernel
  
  Must be subclassed with a publish_msg method implementation which
  sends comm messages through the iopub channel.
class_docstr_tok: ["Class","for","communicating","between","a","Frontend","and","a","Kernel","Must","be","subclassed","with","a","publish_msg","method","implementation","which","sends","comm","messages","through","the","iopub","channel","."]
docstr: Register a callback for comm_msg
  
  Will be called with the `data` of any comm_msg messages.
  
  Call `on_msg(None)` to disable an existing callback.
docstr_tok: ["Register","a","callback","for","comm_msg","Will","be","called","with","the","`","data","`","of","any","comm_msg","messages",".","Call","`","on_msg","(","None",")","`","to","disable","an","existing","callback","."]
code: def on_msg(self, callback: CommCallback | None) -> None:
      """Register a callback for comm_msg
  
      Will be called with the `data` of any comm_msg messages.
  
      Call `on_msg(None)` to disable an existing callback.
      """
      self._msg_callback = callback
  
imports: from __future__ import annotations
  import contextlib
  import logging
  import typing
  import uuid
  from traitlets.utils.importstring import import_item
  import comm
label_desc: Use image node_id 8 for calling the BaseComm obj's underlying member method code with example usage: obj.on_msg(callback) without return types