beetbox/confuse

Race condition when creating config file directory

ryanrichholt opened this issue · 2 comments

confuse/confuse/core.py

Lines 647 to 649 in 3162e50

# Ensure that the directory exists.
if not os.path.isdir(appdir):
os.makedirs(appdir)

The lines referenced above throw an exception in rare cases when multiple concurrent instances of this code run on a new system. It could be fixed really easy by just adding the exist_ok=True argument.

Ah, good call! In fact, we should probably not have the if at all and just use exist_ok=True. Any chance you could open a tiny PR with that change?

It took a little trial-and-error. The easy solution didn't work for Python 2, but I think I have a solution ready in the PR now. Thanks!