io - Permission denied doing os.mkdir(d) after running shutil.rmtree(d) in Python -


very in windows 7 console if run python program twice does

if os.path.isdir(d):     shutil.rmtree(d) if not os.path.exists(d):     os.mkdir(d) 

where d name of directory many files, "permission denied" mkdir command. if run once, wait seconds, run again not such error. problem here?

there 3 things come mind:

  1. windows delays file operations in order preserve metadata. if example rename file , create 1 in location, windows has time-window things acls transferred new file. "feature" preserve metadata programs write new file before deleting old one, in order not loose data when fails in middle.

  2. malware scanners hook filesystem operations , perform scan on files, searching malware (or government-critic texts, if you're paranoid, , maybe if you're not paranoid). during scan, other accesses file blocked.

  3. lastly, i'm not sure how shutil.rmtree() implemented, under windows, tree operations implemented not os core shell (i.e. explorer) , executed asynchronously, explain short time window in path still blocked though call returned.

i believe e.g. subversion or rather apache portable runtime stumbled across same problem , worked around retrying delay. solution doesn't win beauty contest, seems job(tm).


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -