From 47d5f83bf4c6cdbc05f082a6bca7ef724e08eca4 Mon Sep 17 00:00:00 2001 From: JM Etancelin <jean-matthieu.etancelin@univ-pau.fr> Date: Tue, 24 Mar 2020 16:09:36 +0100 Subject: [PATCH] improve process safety for some io utility functions --- hysop/tools/io_utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hysop/tools/io_utils.py b/hysop/tools/io_utils.py index de637e606..4c989eda0 100755 --- a/hysop/tools/io_utils.py +++ b/hysop/tools/io_utils.py @@ -49,7 +49,10 @@ class IO(object): @requires_cmd('stat') def get_fs_type(path): cmd = ['stat', '-f', '-c', '%T', path] - fs_type = subprocess.check_output(cmd) + fs_type='' + if mpi.main_rank==0: + fs_type = subprocess.check_output(cmd) + fs_type = mpi.main_comm.bcast(fs_type, root=0) return fs_type.replace('\n', '') @classmethod @@ -148,7 +151,8 @@ class IO(object): raise RuntimeError(msg) if not os.path.exists(cpath): try: - os.makedirs(cpath) + if mpi.main_rank==0: + os.makedirs(cpath) except IOError: pass return cpath -- GitLab