Python: Make directory while avoiding race conditions