mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 18:34:18 +00:00
Hups
This commit is contained in:
parent
8a607b6dc0
commit
0392d25464
@ -7,7 +7,15 @@ from .CQiWrapper.CQiWrapper import CQiWrapper
|
||||
import logging
|
||||
|
||||
|
||||
'''
|
||||
' A dictionary containing lists of with corpus ids associated Socket.IO session
|
||||
' ids (sid). {<corpus_id>: [<sid>, ...], ...}
|
||||
'''
|
||||
analysis_sessions = {}
|
||||
'''
|
||||
' A dictionary containing Socket.IO session id - CQi client pairs.
|
||||
' {<sid>: CQi client, ...}
|
||||
'''
|
||||
analysis_clients = {}
|
||||
|
||||
|
||||
@ -26,7 +34,13 @@ def init_corpus_analysis(corpus_id):
|
||||
def recv_query(message):
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.warning(message)
|
||||
# analysis_client = analysis_clients[request.sid]
|
||||
analysis_client = analysis_clients[request.sid]
|
||||
corpus_name = 'CORPUS'
|
||||
result_subcorpus_name = 'Query-results' # should be set by the user somehow
|
||||
query = message['query']
|
||||
analysis_client.create_attribute_strings(corpus_name)
|
||||
analysis_client.query_subcorpus(corpus_name, result_subcorpus_name, query)
|
||||
analysis_client.show_results(corpus_name)
|
||||
|
||||
|
||||
def observe_corpus_analysis_connection(app, corpus_id, session_id):
|
||||
@ -40,18 +54,16 @@ def observe_corpus_analysis_connection(app, corpus_id, session_id):
|
||||
password='opaque', port=4877,
|
||||
username='opaque')
|
||||
analysis_client.connect()
|
||||
analysis_clients['session_id'] = analysis_client
|
||||
corpus_name = 'CORPUS'
|
||||
result_subcorpus_name = 'Query-results' # should be set by the user somehow
|
||||
query = '"and";'
|
||||
analysis_client.create_attribute_strings(corpus_name)
|
||||
logger.warning('Log after create_attribute_strings.')
|
||||
analysis_client.query_subcorpus(corpus_name, result_subcorpus_name, query)
|
||||
logger.warning('Log after query_subcorpus.')
|
||||
analysis_client.show_results(corpus_name)
|
||||
analysis_clients[session_id] = analysis_client
|
||||
while session_id in connected_sessions:
|
||||
logger.warning(analysis_client.ctrl_ping())
|
||||
socketio.sleep(3)
|
||||
try:
|
||||
analysis_client.ctrl_ping()
|
||||
except Exception as err:
|
||||
logger.warning('[Exception]: {}'.format(err))
|
||||
break
|
||||
else:
|
||||
socketio.sleep(3)
|
||||
analysis_client.disconnect()
|
||||
analysis_clients.pop(session_id, None)
|
||||
analysis_sessions[str(corpus_id)].remove(session_id)
|
||||
if not analysis_sessions[str(corpus_id)]:
|
||||
|
Loading…
Reference in New Issue
Block a user