code: def _new_connection_file(self):
          
          # Check if jupyter_runtime_dir exists (Spyder addition)
          if not osp.isdir(jupyter_runtime_dir()):
              try:
                  os.makedirs(jupyter_runtime_dir())
              except (IOError, OSError):
                  return None
          cf = ''
          while not cf:
              ident = str(uuid.uuid4()).split('-')[-1]
              cf = os.path.join(jupyter_runtime_dir(), 'kernel-%s.json' % ident)
              cf = cf if not os.path.exists(cf) else ''
          return cf
docs: Generate a new connection file
  
          Taken from jupyter_client/console_app.py
          Licensed under the BSD license