diff --git a/app/corpora/cqi_over_sio/__init__.py b/app/corpora/cqi_over_sio/__init__.py index 888bfaae..a5564d39 100644 --- a/app/corpora/cqi_over_sio/__init__.py +++ b/app/corpora/cqi_over_sio/__init__.py @@ -1,13 +1,14 @@ from cqi import CQiClient from cqi.errors import CQiException from cqi.status import CQiStatus -from flask import session +from docker.models.containers import Container +from flask import current_app, session from flask_login import current_user from flask_socketio import Namespace from inspect import signature from threading import Lock from typing import Callable, Dict, List, Optional -from app import db, hashids, socketio +from app import db, docker_client, hashids, socketio from app.decorators import socketio_login_required from app.models import Corpus, CorpusStatus from . import extensions @@ -121,7 +122,10 @@ class CQiNamespace(Namespace): socketio.sleep(3) retry_counter -= 1 db.session.refresh(db_corpus) - cqi_client: CQiClient = CQiClient(f'cqpserver_{db_corpus_id}') + cqpserver_container_name: str = f'cqpserver_{db_corpus_id}' + cqpserver_container: Container = docker_client.containers.get(cqpserver_container_name) + cqpserver_host: str = cqpserver_container.attrs['NetworkSettings']['Networks'][current_app.config['NOPAQUE_DOCKER_NETWORK_NAME']]['IPAddress'] + cqi_client: CQiClient = CQiClient(cqpserver_host) session['cqi_over_sio'] = { 'cqi_client': cqi_client, 'cqi_client_lock': Lock(),