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

def recover(self, job, job_wrapper):

    job_id = job.get_job_runner_external_id()
    if (job_id is None):
        self.put(job_wrapper)
        return
    ajs = AsynchronousJobState(files_dir=job_wrapper.working_directory, job_wrapper=job_wrapper)
    ajs.job_id = str(job_id)
    ajs.command_line = job.get_command_line()
    ajs.job_wrapper = job_wrapper
    ajs.job_destination = job_wrapper.job_destination
    if (job.state == model.Job.states.RUNNING):
        log.debug(('(%s/%s)    is    still    in    running    state,    adding    to    the    DRM    queue' % (job.get_id(), job.get_job_runner_external_id())))
        ajs.old_state = drmaa.JobState.RUNNING
        ajs.running = True
        self.monitor_queue.put(ajs)
    elif (job.get_state() == model.Job.states.QUEUED):
        log.debug(('(%s/%s)    is    still    in    DRM    queued    state,    adding    to    the    DRM    queue' % (job.get_id(), job.get_job_runner_external_id())))
        ajs.old_state = drmaa.JobState.QUEUED_ACTIVE
        ajs.running = False
        self.monitor_queue.put(ajs)
