Skip to content
Snippets Groups Projects
Commit 47d5f83b authored by EXT Jean-Matthieu Etancelin's avatar EXT Jean-Matthieu Etancelin
Browse files

improve process safety for some io utility functions

parent a84e0fa6
No related branches found
No related tags found
1 merge request!16MPI operators
...@@ -49,7 +49,10 @@ class IO(object): ...@@ -49,7 +49,10 @@ class IO(object):
@requires_cmd('stat') @requires_cmd('stat')
def get_fs_type(path): def get_fs_type(path):
cmd = ['stat', '-f', '-c', '%T', 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', '') return fs_type.replace('\n', '')
@classmethod @classmethod
...@@ -148,7 +151,8 @@ class IO(object): ...@@ -148,7 +151,8 @@ class IO(object):
raise RuntimeError(msg) raise RuntimeError(msg)
if not os.path.exists(cpath): if not os.path.exists(cpath):
try: try:
os.makedirs(cpath) if mpi.main_rank==0:
os.makedirs(cpath)
except IOError: except IOError:
pass pass
return cpath return cpath
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment