docs: def set_pid():
      """
      Explicitly ask the ipython kernel for its pid
      """
      global pid
      lines = '\n'.join(['import os', '_pid = os.getpid()'])
  
      try:
          msg_id = send(lines, silent=True, user_variables=['_pid'])
      except TypeError: # change in IPython 3.0+
          msg_id = send(lines, silent=True, user_expressions={'_pid':'_pid'})
  
      # wait to get message back from kernel
      try:
          child = get_child_msg(msg_id)
      except Empty:
          echo("no reply from IPython kernel")
          return
      try:
          pid = int(child['content']['user_variables']['_pid'])
      except TypeError: # change in IPython 1.0.dev moved this out
          pid = int(child['content']['user_variables']['_pid']['data']['text/plain'])
      except KeyError:    # change in IPython 3.0+
          pid = int(
              child['content']['user_expressions']['_pid']['data']['text/plain'])
      except KeyError: # change in IPython 1.0.dev moved this out
          echo("Could not get PID information, kernel not running Python?")
      return pid