'Recovers jobs stuck in the queued/running state when Galaxy started'

def recover(self, job, job_wrapper):

    '    This    method    is    called    by    galaxy    at    the    time    of    startup.\n                                                Jobs    in    Running    &    Queued    status    in    galaxy    are    put    in    the    monitor_queue    by    creating    an    AsynchronousJobState    object\n                                '
    job_id = job_wrapper.job_id
    ajs = AsynchronousJobState(files_dir=job_wrapper.working_directory, job_wrapper=job_wrapper)
    ajs.job_id = str(job_id)
    ajs.job_destination = job_wrapper.job_destination
    job_wrapper.command_line = job.command_line
    ajs.job_wrapper = job_wrapper
    if (job.state == model.Job.states.RUNNING):
        log.debug(('(%s/%s)    is    still    in    running    state,    adding    to    the    god    queue' % (job.id, job.get_job_runner_external_id())))
        ajs.old_state = 'R'
        ajs.running = True
        self.monitor_queue.put(ajs)
    elif (job.state == model.Job.states.QUEUED):
        log.debug(('(%s/%s)    is    still    in    god    queued    state,    adding    to    the    god    queue' % (job.id, job.get_job_runner_external_id())))
        ajs.old_state = 'Q'
        ajs.running = False
        self.monitor_queue.put(ajs)
