Use APScheduler to handle job execution.

This commit is contained in:
Patrick Jentsch
2019-08-12 17:03:12 +02:00
parent 344ba1a8e2
commit faf54e57fa
6 changed files with 62 additions and 44 deletions

View File

@ -22,7 +22,7 @@ def nlp():
service='nlp',
service_args=json.dumps(['-l {}'.format(new_nlp_job_form.language.data)]),
service_version=new_nlp_job_form.version.data,
status='submitted',
status='preparing',
title=new_nlp_job_form.title.data)
db.session.add(nlp_job)
@ -48,8 +48,8 @@ def nlp():
' NOTE: Using self created threads is just for testing purpose as
' there is no scheduler available.
'''
thread = Thread(target=swarm.run, args=(nlp_job.id,))
thread.start()
nlp_job.status = 'submitted'
db.session.commit()
flash('Job created!')
return redirect(url_for('services.nlp'))
@ -74,7 +74,7 @@ def ocr():
'-l {}'.format(new_ocr_job_form.language.data),
'--skip-binarisation']),
service_version=new_ocr_job_form.version.data,
status='submitted',
status='preparing',
title=new_ocr_job_form.title.data)
db.session.add(ocr_job)
@ -94,14 +94,8 @@ def ocr():
else:
for file in new_ocr_job_form.files.data:
file.save(os.path.join(dir, file.filename))
'''
' TODO: Let the scheduler run this job in the background.
'
' NOTE: Using self created threads is just for testing purpose as
' there is no scheduler available.
'''
thread = Thread(target=swarm.run, args=(ocr_job.id,))
thread.start()
ocr_job.status = 'submitted'
db.session.commit()
flash('Job created!')
return redirect(url_for('services.ocr'))