folder_location = '/tmp/example_dir'
try:
    os.mkdir(folder_location)
except OSError as e:
    if e.errno == errno.EEXIST and os.path.isdir(folder_location):
        pass
else:
    raise
Race-condition creating folder in Python