code: def robust_rmtree(self, path, max_retries=3):
          
          
          delay = 1
          for _ in range(max_retries):
              try:
                  shutil.rmtree(path)
                  break
              except OSError:
                  logger.debug('Unable to remove path: {}.  Retrying in {} seconds.'.format(path, delay))
                  time.sleep(delay)
                  delay *= 2
  
          if os.path.exists(path):
              # Final attempt, pass any Exceptions up to caller.
              shutil.rmtree(path)
docs: Robustly tries to delete paths.
  
          Retries several times (with increasing delays) if an OSError
          occurs.  If the final attempt fails, the Exception is propagated
          to the caller.
  
          Borrowing patterns from:
          https://github.com/hashdist/hashdist