示例#1
0
def kill_calculation(calculation, transport):
    """
    Kill the calculation through the scheduler

    :param calculation: the instance of CalcJobNode to kill.
    :param transport: an already opened transport to use to address the scheduler
    """
    job_id = calculation.get_job_id()

    # Get the scheduler plugin class and initialize it with the correct transport
    scheduler = calculation.computer.get_scheduler()
    scheduler.set_transport(transport)

    # Call the proper kill method for the job ID of this calculation
    result = scheduler.kill(job_id)

    if result is not True:

        # Failed to kill because the job might have already been completed
        running_jobs = scheduler.get_jobs(jobs=[job_id], as_dict=True)
        job = running_jobs.get(job_id, None)

        # If the job is returned it is still running and the kill really failed, so we raise
        if job is not None and job.job_state != JobState.DONE:
            raise exceptions.RemoteOperationError(
                'scheduler.kill({}) was unsuccessful'.format(job_id))
        else:
            execlogger.warning(
                'scheduler.kill() failed but job<{%s}> no longer seems to be running regardless',
                job_id)

    return True
示例#2
0
def kill_calculation(calculation, transport):
    """
    Kill the calculation through the scheduler

    :param calculation: the instance of JobCalculation to kill.
    :param transport: an already opened transport to use to address the scheduler
    """
    job_id = calculation.get_job_id()

    # Get the scheduler plugin class and initialize it with the correct transport
    scheduler = calculation.get_computer().get_scheduler()
    scheduler.set_transport(transport)

    # Call the proper kill method for the job ID of this calculation
    result = scheduler.kill(job_id)

    if result is not True:
        raise exceptions.RemoteOperationError(
            'scheduler.kill({}) was unsuccessful'.format(job_id))
    else:
        calculation._set_scheduler_state(JOB_STATES.DONE)