def get_open_files(path, log_open=False):
    'Get open files under a path\n\n    Note: This function is very slow on Windows.\n\n    Parameters\n    ----------\n    path : str\n      File or directory to check for open files under\n    log_open : bool or int\n      If set - logger level to use\n\n    Returns\n    -------\n    dict\n      path : pid\n\n    '
    import psutil
    files = {}
    path = str(Path(path).resolve().absolute())
    for proc in psutil.process_iter():
        try:
            open_paths = ([p.path for p in proc.open_files()] + [proc.cwd()])
            for p in open_paths:
                if path_startswith(p, path):
                    files[p] = proc
        except psutil.NoSuchProcess:
            pass
        except psutil.AccessDenied:
            pass
    if (files and log_open):
        lgr.log(log_open, 'Open files under %s: %s', path, files)
    return files
Get open files under a path

Note: This function is very slow on Windows.

Parameters
----------
path : str
  File or directory to check for open files under
log_open : bool or int
  If set - logger level to use

Returns
-------
dict
  path : pid
def get_open_files(path, log_open=False):
    'Get open files under a path\n\n    Note: This function is very slow on Windows.\n\n    Parameters\n    ----------\n    path : str\n      File or directory to check for open files under\n    log_open : bool or int\n      If set - logger level to use\n\n    Returns\n    -------\n    dict\n      path : pid\n\n    '
    import psutil
    files = {}
    path = str(Path(path).resolve().absolute())
    for proc in psutil.process_iter():
        try:
            open_paths = ([p.path for p in proc.open_files()] + [proc.cwd()])
            for p in open_paths:
                if path_startswith(p, path):
                    files[p] = proc
        except psutil.NoSuchProcess:
            pass
        except psutil.AccessDenied:
            pass
    if (files and log_open):
        lgr.log(log_open, 'Open files under %s: %s', path, files)
    return files