code: def _cleanup_temp_dir(self, base_dir):
          
          if self._should_cleanup_temp_dir:
              logging.debug('Cleaning up temporary directory %s.', base_dir)
              if self._user is None:
                  util.rmtree(base_dir, onerror=util.log_rmtree_error)
              else:
                  rm = subprocess.Popen(self._build_cmdline(['rm', '-rf', '--', base_dir]),
                                        stderr=subprocess.PIPE)
                  rm_output = rm.stderr.read().decode()
                  rm.stderr.close()
                  if rm.wait() != 0 or rm_output:
                      logging.warning("Failed to clean up temp directory %s: %s.",
                                      base_dir, rm_output)
          else:
              logging.info("Skipping cleanup of temporary directory %s.", base_dir)
docs: Delete given temporary directory and all its contents.