Catching RuntimeError with h5py and mpi4py


I’ve noticed a specific problem with h5py and mpi4py which I can’t seem to resolve. The following code:

import h5py
from mpi4py import MPI
f = h5py.File("dummy.h5", "w", driver='mpio', comm=MPI.COMM_WORLD)
# f.close()
if MPI.COMM_WORLD.rank == 0:
    raise RuntimeError("I'd like to abort please")

when run with mpirun -n 2 python3 -m mpi4py should cause mpi4py to call MPI_Abort() - but it just hangs.
If I don’t open the HDF5 file, or if I close it again, then all is well.

However, I would like to be able to raise an error condition whilst the file is still open.
Does anyone know why this is happening (i.e. why having an open HDF5 file is preventing mpi4py from exiting correctly)?

Many thanks!