nopaque/web/app/jobs/tasks.py
2020-07-10 11:36:54 +02:00

24 lines
611 B
Python

from .. import db
from ..decorators import background
from ..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('Job {} not found'.format(job_id))
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('Job {} not found'.format(job_id))
job.restart()
db.session.commit()