Here is my question code:
Import the random
The from mpi4py import MPI
Comm=MPI.COM M_WORLD
Rank=comm. Get_rank ()
Size=comm. Get_size ()
If rank==0:
Print (" Hello World000000000000000000000 ")
For dest in range (2, the size, 2) :
Data=https://bbs.csdn.net/topics/comm.recv (source=dest, tag=dest)
If rank==1:
Print (" Hello World111111111111111111111 ")
For dest in range (3, size, 2) :
Data=https://bbs.csdn.net/topics/comm.recv (source=dest, tag=dest)
The else:
Data=(1, 10)
https://bbs.csdn.net/topics/random.randintComm. Send (data, dest=rank % 2, tag=rank)
Print (" process {0} sends data {1} to {2} ". The format (rank, data, rank % 2))

When I use two if instead of the else, the program can normal exit:
Import the random
The from mpi4py import MPI
Comm=MPI.COM M_WORLD
Rank=comm. Get_rank ()
Size=comm. Get_size ()
If rank==0:
Print (" Hello World000000000000000000000 ")
For dest in range (2, the size, 2) :
Data=https://bbs.csdn.net/topics/comm.recv (source=dest, tag=dest)
If rank==1:
Print (" Hello World111111111111111111111 ")
For dest in range (3, size, 2) :
Data=https://bbs.csdn.net/topics/comm.recv (source=dest, tag=dest)
If rank==2:
Data=(1, 10)
https://bbs.csdn.net/topics/random.randintComm. Send (data, dest=rank % 2, tag=rank)
Print (" process {0} sends data {1} to {2} ". The format (rank, data, rank % 2))
If rank==3:
Data=(1, 10)
https://bbs.csdn.net/topics/random.randintComm. Send (data, dest=rank % 2, tag=rank)
Print (" process {0} sends data {1} to {2} ". The format (rank, data, rank % 2))
