You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This checks if a directory exists and then calls mkdir to create it. During automation or scripting where parallelism can come into play this can cause a race condition easily:
knack.util.ensure_dir
defensure_dir(d):
""" Create a directory if it doesn't exist """ifnotos.path.isdir(d):
os.makedirs(d)
To prevent this race condition, use try/expect: to create the directory, then ignore "File exists" errors, which mean the directory was there.
try:
os.makedirs(path)
except OSError as e:
if e.errno != errno.EEXIST:
raise
Or for 3.2+
os.makedirs('/path/to/dir', exist_ok=True)
The text was updated successfully, but these errors were encountered:
This checks if a directory exists and then calls mkdir to create it. During automation or scripting where parallelism can come into play this can cause a race condition easily:
knack.util.ensure_dir
To prevent this race condition, use try/expect: to create the directory, then ignore "File exists" errors, which mean the directory was there.
Or for 3.2+
The text was updated successfully, but these errors were encountered: