Skip to content

Commit 87f69b7

Browse files
authored
fix: account for possible race condition when creating /opt/ml/code (#231)
1 parent 874f7b0 commit 87f69b7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/sagemaker_training/environment.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ def _create_training_directories():
183183
def _create_code_dir(): # type: () -> None
184184
"""Create /opt/ml/code when the module is imported."""
185185
if not os.path.exists(code_dir):
186-
os.makedirs(code_dir)
186+
try:
187+
os.makedirs(code_dir)
188+
except FileExistsError:
189+
pass # Another process created the directory
187190

188191

189192
_create_code_dir()

0 commit comments

Comments
 (0)