Ejemplo n.º 1
0
 def run_do(self):
     logger.info("{} job are running.".format(running_job_amount()))
     try:
         if running_job_amount() < MAX_CONCURRENT_JOB_RUN:
             wait_jobs = get_job_from_queue(status="waiting", limit=1)
             if wait_jobs:
                 wait_job = wait_jobs[0]
                 run_job_id = wait_job.job_id
                 try:
                     run_job_success = self.run_job(job_id=run_job_id,
                                                    config=json.loads(
                                                        wait_job.config))
                 except Exception as e:
                     run_job_success = False
                     logger.exception(e)
                 if run_job_success:
                     update_job_queue(job_id=run_job_id,
                                      role=wait_job.role,
                                      party_id=wait_job.party_id,
                                      save_data={"status": "ready"})
                 else:
                     pop_from_job_queue(job_id=run_job_id)
         logger.info("check waiting jobs done.")
         self.check_job()
     except Exception as e:
         logger.exception(e)
Ejemplo n.º 2
0
 def run_do(self):
     logger.info("{} job are running.".format(running_job_amount()))
     if running_job_amount() < MAX_CONCURRENT_JOB_RUN:
         wait_jobs = get_job_from_queue(status="waiting", limit=1)
         if wait_jobs:
             update_job_queue(job_id=wait_jobs[0].get("job_id"), update_data={"status": "ready"})
             self.run_job(wait_jobs[0].get("job_id"), json.loads(wait_jobs[0].get("config")))
Ejemplo n.º 3
0
 def check_job(self):
     running_jobs = get_job_from_queue(status="running", limit=0)
     for running_job in running_jobs:
         if running_job.pid and not check_job_process(running_job.pid):
             local_api(method='POST',
                       suffix='/job/jobStatus/{}/{}/{}'.format(
                           running_job.job_id, running_job.role,
                           running_job.party_id),
                       json_body={'status': 'failed'})