Exemple #1
0
def _cleanupOnCancel(signum, _frame):
    """Helper function to clean up upon cancellation."""
    print(
        "Caught Cancel signal ({}); cleaning temporary files and exiting..."
        "".format(signum),
        file=sys.stderr,
    )
    context.cleanTempDirs()
    sys.stdout.flush()
    sys.stderr.flush()
    sys.exit(1)  # since we're handling the signal we have to cancel
Exemple #2
0
def main():
    # Main entry point into ARMI
    try:
        if not isConfigured():
            configure(apps.App())
        code = ArmiCLI().run()
        # sys exit interprets None as 0
        sys.exit(code)
    except Exception:
        # Make sure not to catch all BaseExceptions, lest we catch the expected
        # SystemExit exception
        import traceback

        # TODO: change to critical after critical no longer throws an exception.
        print(
            "[CRIT {:03} ] Unhandled exception in __main__ on {}.".format(
                context.MPI_RANK, context.MPI_NODENAME),
            file=sys.__stderr__,
        )
        print(
            "[CRIT {:03} ] Stack trace: {}".format(context.MPI_RANK,
                                                   traceback.format_exc()),
            file=sys.__stderr__,
        )
        if context.MPI_SIZE > 1:
            print(
                "[CRIT {:03} ] killing all MPI tasks from __main__.\n".format(
                    context.MPI_RANK),
                file=sys.__stderr__,
            )
            # cleanTempDirs has @atexit.register so it should be called at the end, but mpi.Abort in main
            # will not allow for @atexit.register or except/finally code to be called so calling here as well
            context.cleanTempDirs()
            # .Abort will not allow for @atexit.register or except/finally code to be called
            context.MPI_COMM.Abort(errorcode=-1)
        raise SystemExit(1)
Exemple #3
0
 def invoke(self):
     # get the case title.
     context.cleanTempDirs(0)
Exemple #4
0
 def invoke(self):
     context.cleanTempDirs(olderThanDays=0)