mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-12 00:50:40 +00:00
Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/opaque into development
This commit is contained in:
@ -2,5 +2,4 @@ from flask import Blueprint
|
||||
|
||||
corpora = Blueprint('corpora', __name__)
|
||||
|
||||
|
||||
from . import views
|
||||
from . import events, views
|
||||
|
34
app/corpora/events.py
Normal file
34
app/corpora/events.py
Normal file
@ -0,0 +1,34 @@
|
||||
from app import db, socketio
|
||||
from app.events import connected_sessions
|
||||
from app.models import Corpus
|
||||
from flask import current_app, request
|
||||
from flask_login import login_required
|
||||
import logging
|
||||
|
||||
|
||||
@socketio.on('init_corpus_analysis')
|
||||
@login_required
|
||||
def init_corpus_analysis(corpus_id):
|
||||
''' TODO: Check if current_user is allowed to subscribe to this '''
|
||||
socketio.start_background_task(observe_corpus_analysis_connection,
|
||||
current_app._get_current_object(),
|
||||
corpus_id,
|
||||
request.sid)
|
||||
|
||||
|
||||
@socketio.on('query_event')
|
||||
def recv_query(message):
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.warning(message)
|
||||
|
||||
|
||||
def observe_corpus_analysis_connection(app, corpus_id, session_id):
|
||||
logger = logging.getLogger(__name__)
|
||||
with app.app_context():
|
||||
while session_id in connected_sessions:
|
||||
logger.warning('Run container, run!')
|
||||
socketio.sleep(3)
|
||||
corpus = Corpus.query.filter_by(id=corpus_id).first()
|
||||
corpus.status = 'stop analysis'
|
||||
db.session.commit()
|
||||
logger.warning('Stop container, stop!')
|
Reference in New Issue
Block a user