def process(job_config, settings):
    for job_id, schedule_time, execution_time, status, runs, uid in get_job_info(job_config.get('id'),
                                                                                 db_name=settings.metadata):

        if status == job_status.get('failed'):
            if (int(job_config.get('retry')) if job_config.get('retry') else 0) > int(runs):
                settings.logger.debug(
                    '%s runs %s. set retries %s.' % (job_config.get('id'), runs, job_config.get('retry')))
                if dependencies_are_met(job_config, schedule_time, settings):
                    set_ready(job_config.get('id'), schedule_time, db_name=settings.metadata)
                    settings.logger.info('Job "%s" "%s" set as ready' % (job_config.get('id'), schedule_time))
                    run(job_config, schedule_time, settings)
                    continue
                else:
                    continue
            else:
                continue
        elif status == job_status.get('running'):
            check_running_job_progress(job_config, schedule_time, uid, settings)
            continue
        elif status == job_status.get('ready'):
            run(job_config, schedule_time, settings)
        elif status == job_status.get('succeeded'):
            continue
        elif status == job_status.get('not_ready'):
            if dependencies_are_met(job_config, schedule_time, settings):
                set_ready(job_config.get('id'), schedule_time, db_name=settings.metadata)
                settings.logger.info('Job "%s" "%s" set as ready' % (job_config.get('id'), schedule_time))
                run(job_config, schedule_time, settings)
            else:
                continue
        else:
            settings.logger.error('Unknown job status "%s"' % status)
            sys.exit(1)
    def test_process_after_ready(self):
        return True
        self._init()
        job_config = self.jobs_config[0]

        dummy_command = '#!/bin/bash\nsleep 5\nexit 0'
        dummy_script = job_config.get('remote_action').get('script')

        with open(dummy_script, 'w') as f:
            f.write(dummy_command)

        job_schedule_time = read_all_jobs(db_name=settings.metadata)[0][1]

        set_ready(job_config.get('id'), job_schedule_time, db_name=settings.metadata)

        process(job_config, settings)

        @execute_db('Initializing...')
        def list_running_jobs(db_name=settings.metadata):
            return 'SELECT * FROM job_status WHERE status = 2;'

        @execute_db('Initializing...')
        def list_finished_jobs(db_name=settings.metadata):
            return 'SELECT * FROM job_status WHERE status = 3;'

        running_jobs = list_running_jobs(db_name=settings.metadata)

        self.assertEqual(len(running_jobs), 1)

        sleep(8)

        process(job_config, settings)

        finished_jobs = list_finished_jobs(db_name=settings.metadata)

        self.assertEqual(len(finished_jobs), 1)

        new_running_jobs = list_running_jobs(db_name=settings.metadata)

        self.assertEqual(len(new_running_jobs), 1)

        os.unlink(settings.metadata)
        os.unlink(dummy_script)