From 0cb51a34c4ef15e5a4e2616616c7b44e539b023f Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Thu, 13 Feb 2020 15:08:15 +0100 Subject: [PATCH] Remove unnecessary job status --- app/models.py | 15 ++++++++++----- app/services/views.py | 10 +++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/models.py b/app/models.py index 5aeb8f17..e72d7860 100644 --- a/app/models.py +++ b/app/models.py @@ -322,11 +322,16 @@ class Job(db.Model): """ Delete the job and its inputs and outputs from database and filesystem. """ - self.status = 'stopping' - db.session.commit() - while self.status != 'deleted': - sleep(1) - db.session.refresh(self) + if self.status != 'complete' and self.status != 'failed': + self.status = 'canceling' + db.session.commit() + while self.status != 'canceled': + # In case the daemon started a submitted job meanwhile + if self.status == 'running': + self.status = 'canceling' + db.session.commit() + sleep(1) + db.session.refresh(self) path = os.path.join(current_app.config['NOPAQUE_STORAGE'], str(self.user_id), 'jobs', str(self.id)) try: diff --git a/app/services/views.py b/app/services/views.py index 925bb472..971a1868 100644 --- a/app/services/views.py +++ b/app/services/views.py @@ -51,16 +51,16 @@ def service(service): db.session.add(job) db.session.commit() relative_dir = os.path.join(str(job.user_id), 'jobs', str(job.id)) - absolut_dir = os.path.join( - current_app.config['NOPAQUE_STORAGE'], relative_dir) + absolut_dir = os.path.join(current_app.config['NOPAQUE_STORAGE'], + relative_dir) try: os.makedirs(absolut_dir) except OSError: job.delete() flash('Internal Server Error') - return make_response( - {'redirect_url': url_for('services.service', service=service)}, - 500) + return make_response({'redirect_url': url_for('services.service', + service=service)}, + 500) else: for file in add_job_form.files.data: filename = secure_filename(file.filename)