'Separated out so we can use the worker threads for it.'

def fail_job(self, pbs_job_state):

    if pbs_job_state.stop_job:
        self.stop_job(self.sa_session.query(self.app.model.Job).get(pbs_job_state.job_wrapper.job_id))
    pbs_job_state.job_wrapper.fail(pbs_job_state.fail_message)
    if (pbs_job_state.job_wrapper.cleanup_job == 'always'):
        self.cleanup((pbs_job_state.output_file, pbs_job_state.error_file, pbs_job_state.exit_code_file, pbs_job_state.job_file))
