Esempio n. 1
0
 def testException(self):
     success = MPI.Exception(MPI.SUCCESS)
     lasterr = MPI.Exception(MPI.ERR_LASTCODE)
     for ierr in self.errorclasses:
         errstr = MPI.Get_error_string(ierr)
         errcls = MPI.Get_error_class(ierr)
         errexc = MPI.Exception(ierr)
         self.assertEqual(errexc.error_code, ierr)
         self.assertEqual(errexc.error_class, ierr)
         self.assertEqual(errexc.error_string, errstr)
         self.assertEqual(repr(errexc), "MPI.Exception(%d)" % ierr)
         self.assertEqual(str(errexc), errstr)
         self.assertEqual(int(errexc), ierr)
         self.assertEqual(hash(errexc), hash(errexc.error_code))
         self.assertTrue(errexc == ierr)
         self.assertTrue(errexc == errexc)
         self.assertFalse(errexc != ierr)
         self.assertFalse(errexc != errexc)
         self.assertTrue(success <= ierr <= lasterr)
         self.assertTrue(success <= errexc <= lasterr)
         self.assertTrue(errexc >= ierr)
         self.assertTrue(errexc >= success)
         self.assertTrue(lasterr >= ierr)
         self.assertTrue(lasterr >= errexc)
         if errexc == success:
             self.assertFalse(errexc)
         else:
             self.assertTrue(errexc)
             self.assertTrue(errexc > success)
             self.assertTrue(success < errexc)
     exc = MPI.Exception(MPI.SUCCESS - 1)
     self.assertTrue(exc, MPI.ERR_UNKNOWN)
     exc = MPI.Exception(MPI.ERR_LASTCODE + 1)
     self.assertTrue(exc, MPI.ERR_UNKNOWN)
Esempio n. 2
0
 def testException(self):
     from sys import version_info as py_version
     for ierr in self.errorclasses:
         errstr = MPI.Get_error_string(ierr)
         errcls = MPI.Get_error_class(ierr)
         errexc = MPI.Exception(ierr)
         if py_version >= (2, 5):
             self.assertEqual(errexc.error_code, ierr)
             self.assertEqual(errexc.error_class, ierr)
             self.assertEqual(errexc.error_string, errstr)
         self.assertEqual(str(errexc), errstr)
         self.assertEqual(int(errexc), ierr)
         self.assertTrue(errexc == ierr)
         self.assertTrue(errexc == errexc)
         self.assertFalse(errexc != ierr)
         self.assertFalse(errexc != errexc)
Esempio n. 3
0
 def cancel(self, completed):
     self.cancel_called = True
     if completed is not self.completed:
         raise MPI.Exception(MPI.ERR_PENDING)
Esempio n. 4
0
 def cancel(self, completed):
     if completed is not self.completed:
         raise MPI.Exception(MPI.ERR_PENDING)
Esempio n. 5
0
fh.Close()

# error class, error code, error string
# add a new error class
errclass = MPI.Add_error_class()
# add an error code to the new error class
errcode = MPI.Add_error_code(errclass)
# associate an error string with an the error errorcode
MPI.Add_error_string(errcode, 'Example error string')
print 'The new error class:', MPI.Get_error_class(errcode)
print 'The new error string:', MPI.Get_error_string(errcode)

# MPI.Exception
# errexc = MPI.Exception(errclass)
# create an MPI.Exception object from MPI.ERR_OTHER
errexc = MPI.Exception(MPI.ERR_OTHER)
print 'MPI.Exception is a subclass of RuntimeError:', isinstance(
    errexc, RuntimeError)
print 'Error class of MPI.ERR_OTHER:', errexc.Get_error_class()
print 'Error code of MPI.ERR_OTHER:', errexc.Get_error_code()
print 'Error string of MPI.ERR_OTHER:', errexc.Get_error_string()

# show exception catch
try:
    # try to free MPI.COMM_WORLD
    MPI.COMM_WORLD.Free()
except MPI.Exception as e:
    print 'Error class of the Free op:', e.Get_error_class()
    print 'Error code of the Free op:', e.Get_error_code()
    print 'Error string of the Free op:', e.Get_error_string()
Esempio n. 6
0
 def cancel(self, completed):
     if completed is not self.completed:
         #raise AssertionError()
         raise MPI.Exception(MPI.ERR_PENDING)