Skip to content

Commit

Permalink
Fix os.makedirs issue in multithreading (spotify#2039)
Browse files Browse the repository at this point in the history
  • Loading branch information
elnikkis committed Apr 20, 2017
1 parent 734ae68 commit e2ea313
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion luigi/local_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ def mkdir(self, path, parents=True, raise_if_exists=False):
return

if parents:
os.makedirs(path)
error_to_catch = getattr(__builtins__, 'FileExistsError', OSError)
try:
os.makedirs(path)
except error_to_catch as err:
# somebody already created the path
if getattr(err, 'errno', 0) != errno.EEXIST:
raise
else:
if not os.path.exists(os.path.dirname(path)):
raise MissingParentDirectory()
Expand Down

0 comments on commit e2ea313

Please sign in to comment.