diff --git a/clearml/utilities/locks/utils.py b/clearml/utilities/locks/utils.py index 01f2f22d..4a1ea01a 100644 --- a/clearml/utilities/locks/utils.py +++ b/clearml/utilities/locks/utils.py @@ -197,6 +197,11 @@ class Lock(object): def _get_fh(self): '''Get a new filehandle''' + # Create the parent directory if it doesn't exist + path, name = os.path.split(self.filename) + if path and not os.path.isdir(path): # pragma: no cover + os.makedirs(path, exist_ok=True) + return open(self.filename, self.mode, **self.file_open_kwargs) def _get_lock(self, fh):