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:
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.
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.
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
Post a Comment