code: def safe_dump(d, fname, *args, **kwargs):
      
      if osp.exists(fname):
          os.rename(fname, fname + '~')
      lock = fasteners.InterProcessLock(fname + '.lck')
      lock.acquire()
      try:
          with open(fname, 'w') as f:
              ordered_yaml_dump(d, f, *args, **kwargs)
      except:
          raise
      finally:
          lock.release()
docs: Savely dump `d` to `fname` using yaml
  
      This method creates a copy of `fname` called ``fname + '~'`` before saving
      `d` to `fname` using :func:`ordered_yaml_dump`
  
      Parameters
      ----------
      d: object
          The object to dump
      fname: str
          The path where to dump `d`
  
      Other Parameters
      ----------------
      ``*args, **kwargs``
          Will be forwarded to the :func:`ordered_yaml_dump` function