Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shutil.rmtree wrapper that works better on Windows #110

Open
dangunter opened this issue Jul 2, 2020 · 1 comment
Open

Add shutil.rmtree wrapper that works better on Windows #110

dangunter opened this issue Jul 2, 2020 · 1 comment

Comments

@dangunter
Copy link

dangunter commented Jul 2, 2020

Due to per-process file locking in windows, shutil.rmtree sometimes fails where it would succeed a second or three later, once Windows thinks the process is done. A utility function that did this would be very useful in projects that use Pyomo/pyutilib, such as IDAES.

@dangunter
Copy link
Author

e.g. a function of the flavor:

def rmtree_hard(*args):
    for i in range(3):
        try:
            shutil.rmtree(*args)
            return True
        except:
             time.sleep(1)
    return False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant