code: def rm_subdirs(path, onerror=None):
      """Remove all subdirectories in this path.
  
      The directory indicated by `path` is left in place, and its subdirectories
      are erased.
  
      If onerror is set, it is called to handle the error with arguments (func,
      path, exc_info) where func is os.listdir, os.remove, or os.rmdir;
      path is the argument to that function that caused it to fail; and
      exc_info is a tuple returned by sys.exc_info().  If onerror is None,
      an exception is raised.
      """
  
      # NOTE this code is adapted from the one in shutil.rmtree, and is
      # just as fast
  
      names = []
      try:
          names = os.listdir(path)
      except os.error as err:
          if onerror is not None:
              onerror(os.listdir, path, sys.exc_info())
          else:
              raise
  
      for name in names:
          fullname = os.path.join(path, name)
          if os.path.isdir(fullname):
              if onerror is not None:
                  shutil.rmtree(fullname, False, onerror)
              else:
                  # allow the rmtree to fail once, wait and re-try.
                  # if the error is raised again, fail
                  err_count = 0
                  while True:
                      try:
                          shutil.rmtree(fullname, False, None)
                          break
                      except os.error:
                          if err_count > 0:
                              raise
                          err_count += 1
                          time.sleep(RM_SUBDIRS_RETRY_TIME)
  
file_path: mlens/mlens/externals/joblib/disk.py
imports: import errno
  import os
  import shutil
  import sys
  import time
label_desc: Use image node_id 4 for calling a global function with example usage: rm_subdirs(path, onerror) without return types