pypet/utils/helpful_functions.py
def racedirs(path):
    """Like os.makedirs but takes care about race conditions"""
    if os.path.isfile(path):
        raise IOError('Path `%s` is already a file not a directory')
    while True:
        try:
            if os.path.isdir(path):
                # only break if full path has been created or exists
                break
            os.makedirs(path)
        except EnvironmentError as exc:
            # Part of the directory path already exist
            if exc.errno != 17:
                # This error won't be any good
                raise
def racedirs(path):
    if os.path.isfile(path):
        raise IOError('Path `%s` is already a file not a directory')
    while True:
        try:
            if os.path.isdir(path):
                # only break if full path has been created or exists
                break
            os.makedirs(path)
        except EnvironmentError as exc:
            # Part of the directory path already exist
            if exc.errno != 17:
                # This error won't be any good
                raise
def racedirs ( path ) : if os . path . isfile ( path ) : raise IOError ( 'Path `%s` is already a file not a directory' ) while True : try : if os . path . isdir ( path ) : # only break if full path has been created or exists break os . makedirs ( path ) except EnvironmentError as exc : # Part of the directory path already exist if exc . errno != 17 : # This error won't be any good raise
Like os.makedirs but takes care about race conditions
Like os . makedirs but takes care about race conditions