Skip to content

Add utils.rmtree() which waits and tries again if a file is still in use

On Windows the dumper cleanup regularely fails because the created .exe is still in use by some process and shutil.rmtree() fails with:

OSError: [WinError 145] The directory is not empty

I'm not 100% sure what's the cause for this, but searching for similar issues suggests that it might be Windows Defender scanning the newly created .exe file and because it's so short lifed the scanning and deleting conflict.

This adds a helper which tries a few times and waits a bit before giving up. A similar patch has been in MSYS2 for some time: https://github.com/Alexpux/MINGW-packages/blob/d0c39af02a669e45272c713e912ee63b0dd94157/mingw-w64-gobject-introspection/0025-more-tolerant-rmtreeing.patch

Merge request reports