def cleanup(sys=sys, time=time, world=world): error = getattr(sys, 'last_type', None) if error: sys.stdout.flush() sys.stderr.write(('ASE CLEANUP (node %d): %s occurred. ' + 'Calling MPI_Abort!\n') % (world.rank, error)) sys.stderr.flush() # Give other nodes a moment to crash by themselves (perhaps # producing helpful error messages): time.sleep(3) world.abort(42)