Remove job deletion workaround

This commit is contained in:
Patrick Jentsch 2019-11-18 15:55:19 +01:00
parent 6d807d897d
commit 9a475f2ad2

View File

@ -2,6 +2,7 @@ from datetime import datetime
from flask import current_app from flask import current_app
from flask_login import UserMixin, AnonymousUserMixin from flask_login import UserMixin, AnonymousUserMixin
from itsdangerous import BadSignature, TimedJSONWebSignatureSerializer from itsdangerous import BadSignature, TimedJSONWebSignatureSerializer
from time import sleep
from werkzeug.security import generate_password_hash, check_password_hash from werkzeug.security import generate_password_hash, check_password_hash
from . import db, logger, login_manager from . import db, logger, login_manager
import os import os
@ -330,17 +331,10 @@ class Job(db.Model):
self.status = 'stopping' self.status = 'stopping'
db.session.commit() db.session.commit()
while self.status != 'deleted': while self.status != 'deleted':
''' TODO: wait a second ''' sleep(1)
db.session.refresh(self) db.session.refresh(self)
path = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], path = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
str(self.user_id), 'jobs', str(self.id)) str(self.user_id), 'jobs', str(self.id))
'''
' TODO: Remove this workaround by executing the following command
' before service removal.
'
' docker service update --mount-rm <service>
'''
while os.path.exists(path):
try: try:
shutil.rmtree(path) shutil.rmtree(path)
except Exception as e: except Exception as e:
@ -445,13 +439,6 @@ class Corpus(db.Model):
corpus_file.delete() corpus_file.delete()
path = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], path = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
str(self.user_id), 'corpora', str(self.id)) str(self.user_id), 'corpora', str(self.id))
'''
' TODO: Remove this workaround by executing the following command
' before service removal.
'
' docker service update --mount-rm <service>
'''
while os.path.exists(path):
try: try:
shutil.rmtree(path) shutil.rmtree(path)
except Exception as e: except Exception as e: