code: def rename_to_temp(filename):
      
      with _rename_to_temp_lock:
          root, ext = os.path.splitext(filename)
          if len(ext) > 0:
              ext = ext[1:]  # the dot (".") is originally included
          new_name = new_filename(root, ext)
          os.rename(filename, new_name)
          return new_name
docs: *Thread-safe* renames file to temporary filename. Returns new name