code: def safe_concurrent_creation(target_path):
    
    safe_mkdir_for(target_path)
    tmp_path = '{}.tmp.{}'.format(target_path, uuid.uuid4().hex)
    try:
      yield tmp_path
    except Exception:
      rm_rf(tmp_path)
      raise
    else:
      if os.path.exists(tmp_path):
        safe_concurrent_rename(tmp_path, target_path)
docs: A contextmanager that yields a temporary path and renames it to a final target path when the
    contextmanager exits.
  
    Useful when concurrent processes may attempt to create a file, and it doesn't matter who wins.
  
    :param target_path: The final target path to rename the temporary path to.
    :yields: A temporary path containing the original path with a unique (uuid4) suffix.