简体   繁体   中英

python script running with mpirun not stopping if assert on processor 0 fails

I have a python script with a set of operations done in parallel, with the library mpi4py. At the end of the operations the processor with rank 0 executes an assert test. If the assert fails, the process should stop and the program terminate. However, the program doesn't exit and this I guess is because the other processors are holding. How to make the program ending the execution if the assert fails? I run things with a command like:

mpirun -np 10 python myscript.py 

and then I have a line in the code like:

if rank ==0:
    assert mytest()==0

Instead of assert, you should abort.

https://planet.scipy.org/docs/apiref/mpi4py.MPI.Comm-class.html#Abort

if rank == 0:
    if mytest() === 0:
        comm.Abort()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM