I've reduced my issue to this:
import os, shutil
shutil.rmtree("wtf", True)
os.makedirs("wtf")
Now, when I run this I sometimes get the following error:
Traceback (most recent call last):
File "wtf.py", line 4, in <module>
os.makedirs("wtf")
File "C:\Program Files (x86)\Python34\lib\os.py", line 244, in makedirs
mkdir(name, mode)
PermissionError: [WinError 5] Access is denied: 'wtf'
What could be causing this?