mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 10:34:17 +00:00
Set corpus analysis connection stop signal
This commit is contained in:
parent
1389b6b510
commit
5aa777bc11
@ -1,5 +1,6 @@
|
|||||||
from app import socketio
|
from app import db, socketio
|
||||||
from app.events import connected_sessions
|
from app.events import connected_sessions
|
||||||
|
from app.models import Corpus
|
||||||
from flask import current_app, request
|
from flask import current_app, request
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
import logging
|
import logging
|
||||||
@ -9,7 +10,7 @@ import logging
|
|||||||
@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 '''
|
||||||
socketio.start_background_task(init_corpus_analysis_,
|
socketio.start_background_task(observe_corpus_analysis_connection,
|
||||||
current_app._get_current_object(),
|
current_app._get_current_object(),
|
||||||
corpus_id,
|
corpus_id,
|
||||||
request.sid)
|
request.sid)
|
||||||
@ -21,10 +22,13 @@ def recv_query(message):
|
|||||||
logger.warning(message)
|
logger.warning(message)
|
||||||
|
|
||||||
|
|
||||||
def init_corpus_analysis_(app, corpus_id, session_id):
|
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():
|
||||||
while session_id in connected_sessions:
|
while session_id in connected_sessions:
|
||||||
logger.warning('Run container, run!')
|
logger.warning('Run container, run!')
|
||||||
socketio.sleep(3)
|
socketio.sleep(3)
|
||||||
logger.warning('Stop container, stop!')
|
corpus = Corpus.query.filter_by(id=corpus_id).first()
|
||||||
|
corpus.status = 'stop analysis'
|
||||||
|
db.session.commit()
|
||||||
|
logger.warning('Stop container, stop!')
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{% block page_content %}
|
{% block page_content %}
|
||||||
<script>
|
<script>
|
||||||
socket.emit('init_corpus_analysis', {{ corpus.id }});
|
socket.emit('init_corpus_analysis', {{ corpus_id }});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user