mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 19:04:18 +00:00
28 lines
678 B
Python
28 lines
678 B
Python
from app import db
|
|
from app.decorators import background
|
|
from app.models import Job
|
|
|
|
|
|
@background
|
|
def delete_job(job_id, *args, **kwargs):
|
|
with kwargs['app'].app_context():
|
|
job = Job.query.get(job_id)
|
|
if job is None:
|
|
raise Exception(f'Job {job_id} not found')
|
|
job.delete()
|
|
db.session.commit()
|
|
|
|
|
|
@background
|
|
def restart_job(job_id, *args, **kwargs):
|
|
with kwargs['app'].app_context():
|
|
job = Job.query.get(job_id)
|
|
if job is None:
|
|
raise Exception(f'Job {job_id} not found')
|
|
try:
|
|
job.restart()
|
|
except Exception:
|
|
pass
|
|
else:
|
|
db.session.commit()
|