Only sleep between rmtree and mkdir on Windows machines

This makes amalgamate builds slightly faster on non-Windows machines.
This commit is contained in:
Max Bernstein 2023-02-08 14:31:20 -05:00
parent 40c31fd1d1
commit a8bf40c7bf

View File

@ -19,7 +19,12 @@ import time
if os.path.exists("amalgamated"): if os.path.exists("amalgamated"):
shutil.rmtree("amalgamated") shutil.rmtree("amalgamated")
time.sleep(1) if os.name == "nt":
# On Windows, making a directory too soon after shutil.rmtree can fail
# with PermissionError. Sleep for 1 second as a simple hedge against
# this.
# See https://stackoverflow.com/a/60181105/569183
time.sleep(1)
os.mkdir("amalgamated") os.mkdir("amalgamated")
def remove_copied_include(text): def remove_copied_include(text):