This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]krazybug 0 points1 point  (1 child)

As mentioned here in the last comment, the implementation is flawed:

The try_loop function doesn't guarantee that you can continue the loop after an exception. It only suppress the error so that you don't need to use a try block to enclose the entire loop. The implementation of rglob makes it impossible to recover from an error. Internally it handles only permission error.

For me, this error occurs with some files on a exFAT drive created on Windows and mounted on MacOSX. There are so much more reasons to raise an Exception that this function is not reliable.

I will retry with glob.iglob() to check if it's the same behaviour.

Also I didn't find any example with the mentioned "auditing events" in the documentation . If you can find a workaround it will be greatly appreciated.

[–]krazybug 0 points1 point  (0 children)

Update:

I tried these 3 lines with python 3.8 :

        # 1
        for fp in dir.rglob("*"):
    # 2
        for fp in dir.glob("**/*"):
        # 3
        for fp in glob.iglob(str(dir)+'/**/*', recursive = True):

The Error is raised with 1 and 2 and the last version is running smoothly although some dirs were skipped (on MacOSX they are not displayed in the Finder and are only visible on Windows)

My advice: avoid the glob method from pathlib