code: def robust_rmtree(path, logger=None, max_retries=10):
      
  
      for i in range(max_retries):
          try:
              shutil.rmtree(path)
              return
          except OSError:
              if logger:
                  logger.info('Unable to remove path: {}'.format(path))
                  logger.info('Retrying after {} seconds'.format(i**2))
              else:
                  print('Unable to remove path: {}'.format(path), file=sys.stderr)
                  print('Retrying after {} seconds'.format(i**2), file=sys.stderr)
              time.sleep(i**2)
  
      # 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.