mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 10:34:17 +00:00
Remove workaround to wait for container
This commit is contained in:
parent
ebf2f00e0d
commit
03b956c457
@ -5,7 +5,6 @@ from flask import current_app, request
|
||||
from flask_login import login_required
|
||||
from .CQiClient.CQiClient import CQiClient
|
||||
import logging
|
||||
import time
|
||||
|
||||
|
||||
analysis_clients = {}
|
||||
@ -15,7 +14,6 @@ analysis_clients = {}
|
||||
@login_required
|
||||
def init_corpus_analysis(corpus_id):
|
||||
''' TODO: Check if current_user is allowed to subscribe to this '''
|
||||
time.sleep(5) # wait for IP of container only for dev
|
||||
socketio.start_background_task(observe_corpus_analysis_connection,
|
||||
current_app._get_current_object(),
|
||||
corpus_id,
|
||||
@ -33,13 +31,17 @@ def observe_corpus_analysis_connection(app, corpus_id, session_id):
|
||||
logger = logging.getLogger(__name__)
|
||||
with app.app_context():
|
||||
corpus = Corpus.query.filter_by(id=corpus_id).first()
|
||||
logger.warning('MÖÖÖÖP')
|
||||
analysis_client = CQiClient(host=corpus.analysis_container_ip)
|
||||
analysis_client.ctrl_connect('opaque', 'opaque')
|
||||
while corpus.status != 'analysing':
|
||||
db.session.refresh(corpus)
|
||||
socketio.sleep(3)
|
||||
analysis_server = '{}_analysis_container{}'.format(corpus.creator.username, corpus.id)
|
||||
analysis_client = CQiClient(host=analysis_server)
|
||||
analysis_clients[session_id] = analysis_client
|
||||
analysis_client.ctrl_connect('opaque', 'opaque')
|
||||
while session_id in connected_sessions:
|
||||
logger.warning(analysis_client.ctrl_ping())
|
||||
socketio.sleep(3)
|
||||
analysis_client.ctrl_bye()
|
||||
analysis_clients.pop(session_id, None)
|
||||
corpus.status = 'stop analysis'
|
||||
db.session.commit()
|
||||
|
Loading…
Reference in New Issue
Block a user