def push_into_job_queue(job_id, config): job_queue = JobQueue() job_queue.job_id = job_id job_queue.status = 'waiting' job_queue.config = json.dumps(config) job_queue.create_date = datetime.datetime.now() job_queue.save(force_insert=True)
def update_job_queue(job_id, role, party_id, save_data): jobs = JobQueue.select().where(JobQueue.job_id == job_id, JobQueue.role == role, JobQueue.party_id == party_id) is_insert = True if jobs: job_queue = jobs[0] is_insert = False else: job_queue = JobQueue() job_queue.create_date = datetime.datetime.now() job_queue.job_id = job_id job_queue.role = role job_queue.party_id = party_id if 'status' in save_data: if job_queue.status in ['success', 'failed', 'partial', 'deleted']: # Termination status cannot be updated save_data.pop('status') for k, v in save_data.items(): if k in ['job_id', 'role', 'party_id']: continue setattr(job_queue, k, v) if is_insert: try: job_queue.save(force_insert=True) except: job_queue.save() else: job_queue.save() return job_queue
def update_job_queue(job_id, role, party_id, save_data): jobs = JobQueue.select().where(JobQueue.job_id == job_id, JobQueue.role == role, JobQueue.party_id == party_id) is_insert = True if jobs: job_queue = jobs[0] is_insert = False else: job_queue = JobQueue() job_queue.create_date = datetime.datetime.now() job_queue.job_id = job_id job_queue.role = role job_queue.party_id = party_id for k, v in save_data.items(): if k in ['job_id', 'role', 'party_id']: continue setattr(job_queue, k, v) if is_insert: job_queue.save(force_insert=True) else: job_queue.save() return job_queue