code: def testIRecvAndISend(self):
      comm = self.COMM
      size = comm.Get_size()
      rank = comm.Get_rank()
      tmp = allocate(512)
      for smess in messages:
          dst = (rank + 1) % size
          src = (rank - 1) % size
          rreq = comm.irecv(None, src, 0)
          self.assertTrue(rreq)
          sreq = comm.isend(smess, dst, 0)
          self.assertTrue(sreq)
          index1, mess1 = MPI.Request.waitany([sreq, rreq])
          self.assertIn(index1, (0, 1))
          if index1 == 0:
              self.assertFalse(sreq)
              self.assertTrue(rreq)
              self.assertIsNone(mess1)
          else:
              self.assertTrue(sreq)
              self.assertFalse(rreq)
              self.assertEqual(mess1, smess)
          index2, mess2 = MPI.Request.waitany([sreq, rreq])
          self.assertIn(index2, (0, 1))
          self.assertNotEqual(index2, index1)
          self.assertFalse(sreq)
          self.assertFalse(rreq)
          if index2 == 0:
              self.assertIsNone(mess2)
          else:
              self.assertEqual(mess2, smess)
      for smess in messages:
          dst = (rank + 1) % size
          src = (rank - 1) % size
          rreq = comm.irecv(None, src, 0)
          self.assertTrue(rreq)
          sreq = comm.isend(smess, dst, 0)
          self.assertTrue(sreq)
          index1, flag1, mess1 = MPI.Request.testany([sreq, rreq])
          while not flag1:
              index1, flag1, mess1 = MPI.Request.testany([sreq, rreq])
          self.assertIn(index1, (0, 1))
          if index1 == 0:
              self.assertFalse(sreq)
              self.assertTrue(rreq)
              self.assertIsNone(mess1)
          else:
              self.assertTrue(sreq)
              self.assertFalse(rreq)
              self.assertEqual(mess1, smess)
          index2, flag2, mess2 = MPI.Request.testany([sreq, rreq])
          while not flag2:
              index2, flag2, mess2 = MPI.Request.testany([sreq, rreq])
          self.assertIn(index2, (0, 1))
          self.assertNotEqual(index2, index1)
          self.assertFalse(sreq)
          self.assertFalse(rreq)
          if index2 == 0:
              self.assertIsNone(mess2)
          else:
              self.assertEqual(mess2, smess)
      for buf in (None, 512, tmp):
          for smess in messages:
              dst = (rank + 1) % size
              src = (rank - 1) % size
              rreq = comm.irecv(buf, src, 0)
              self.assertTrue(rreq)
              sreq = comm.isend(smess, dst, 0)
              self.assertTrue(sreq)
              dummy, rmess = MPI.Request.waitall([sreq, rreq], [])
              self.assertFalse(sreq)
              self.assertFalse(rreq)
              self.assertIsNone(dummy)
              self.assertEqual(rmess, smess)
      for buf in (None, 512, tmp):
          for smess in messages:
              src = dst = rank
              rreq = comm.irecv(buf, src, 1)
              flag, msg = MPI.Request.testall([rreq])
              self.assertFalse(flag)
              self.assertIsNone(msg)
              sreq = comm.isend(smess, dst, 1)
              while True:
                  flag, msg = MPI.Request.testall([sreq, rreq], [])
                  if not flag:
                      self.assertIsNone(msg)
                      continue
                  (dummy, rmess) = msg
                  self.assertIsNone(dummy)
                  self.assertEqual(rmess, smess)
                  break
  
imports: from mpi4py import MPI
  import mpiunittest
  import threading
  import warnings
  import sys
label_desc: Use image node_id 4 for calling the BaseTestP2PObj obj's underlying member method code with example usage: obj.testIRecvAndISend() without return types