On 18/09/14 11:42, Jan Blechta wrote:
> Some problems (when running in a clean dir) are avoided using this
> (although incorrect) patch. There are race conditions in creation of
> temp dir. It should be done using atomic operation.
> 
> Jan
> 
> 
> ==================================================================
> diff --git a/test/unit/io/python/test_XDMF.py
> b/test/unit/io/python/test_XDMF.py index 9ad65a4..31471f1 100755
> --- a/test/unit/io/python/test_XDMF.py
> +++ b/test/unit/io/python/test_XDMF.py
> @@ -28,8 +28,9 @@ def temppath():
>      filedir = os.path.dirname(os.path.abspath(__file__))
>      basename = os.path.basename(__file__).replace(".py", "_data")
>      temppath = os.path.join(filedir, basename, "")
> -    if not os.path.exists(temppath):
> -        os.mkdir(temppath)
> +    if MPI.rank(mpi_comm_world()) == 0:
> +        if not os.path.exists(temppath):
> +            os.mkdir(temppath)
>      return temppath

There's still a race condition here because ranks other than zero might
try and use temppath before it's created.  I think you want something
like the below:

if MPI.rank(mpi_comm_world()) == 0:
    if not os.path.exists(temppath):
        os.mkdir(temppath)
MPI.barrier(mpi_comm_world())
return temppath

If you're worried about the OS not creating files atomically, you can
always mkdir into a tmp directory and then os.rename(tmp, temppath),
since posix guarantees that renames are atomic.

Lawrence
_______________________________________________
fenics mailing list
[email protected]
http://fenicsproject.org/mailman/listinfo/fenics

Reply via email to