from mpi4py import MPI
import numpy as np
req ={}
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
#modify this function so we don't have a deadlock
send_data1 = np.array([1,2,4,5], dtype='int')
send_data2 = np.array([5,7,8,9], dtype='int')
recv_data1 =np.zeros(4, dtype='int')
recv_data2 =np.zeros(4, dtype='int')
next = (rank + 1)%size
prev = (size + rank -1) % size
req[0]=comm.Isend([send_data1, MPI.INT], dest=next, tag=11)
req[1]=comm.Irecv([recv_data2, MPI.INT], source=next, tag=12)
req[2]=comm.Isend([send_data2, MPI.INT], dest=prev, tag=12)
req[3]=comm.Irecv([recv_data1, MPI.INT], source=prev, tag=11)
MPI.Request.waitall(req)



