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 flask_login import login_required
|
||||||
from .CQiClient.CQiClient import CQiClient
|
from .CQiClient.CQiClient import CQiClient
|
||||||
import logging
|
import logging
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
analysis_clients = {}
|
analysis_clients = {}
|
||||||
@ -15,7 +14,6 @@ analysis_clients = {}
|
|||||||
@login_required
|
@login_required
|
||||||
def init_corpus_analysis(corpus_id):
|
def init_corpus_analysis(corpus_id):
|
||||||
''' TODO: Check if current_user is allowed to subscribe to this '''
|
''' 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,
|
socketio.start_background_task(observe_corpus_analysis_connection,
|
||||||
current_app._get_current_object(),
|
current_app._get_current_object(),
|
||||||
corpus_id,
|
corpus_id,
|
||||||
@ -33,13 +31,17 @@ def observe_corpus_analysis_connection(app, corpus_id, session_id):
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
corpus = Corpus.query.filter_by(id=corpus_id).first()
|
corpus = Corpus.query.filter_by(id=corpus_id).first()
|
||||||
logger.warning('MÖÖÖÖP')
|
while corpus.status != 'analysing':
|
||||||
analysis_client = CQiClient(host=corpus.analysis_container_ip)
|
db.session.refresh(corpus)
|
||||||
analysis_client.ctrl_connect('opaque', 'opaque')
|
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_clients[session_id] = analysis_client
|
||||||
|
analysis_client.ctrl_connect('opaque', 'opaque')
|
||||||
while session_id in connected_sessions:
|
while session_id in connected_sessions:
|
||||||
logger.warning(analysis_client.ctrl_ping())
|
logger.warning(analysis_client.ctrl_ping())
|
||||||
socketio.sleep(3)
|
socketio.sleep(3)
|
||||||
analysis_client.ctrl_bye()
|
analysis_client.ctrl_bye()
|
||||||
|
analysis_clients.pop(session_id, None)
|
||||||
corpus.status = 'stop analysis'
|
corpus.status = 'stop analysis'
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user