Move event handlers to a dedicated event directory

This commit is contained in:
Patrick Jentsch 2021-09-07 13:50:23 +02:00
parent 0861d931ce
commit 9d59aa3409
4 changed files with 11 additions and 11 deletions

View File

@ -32,8 +32,8 @@ def create_app(config_name):
app, message_queue=app.config['NOPAQUE_SOCKETIO_MESSAGE_QUEUE_URI'])
with app.app_context():
from . import socketio_events
from . import sqlalchemy_events
from .events import socketio as socketio_events
from .events import sqlalchemy as sqlalchemy_events
from .admin import admin as admin_blueprint
from .auth import auth as auth_blueprint
from .corpora import corpora as corpora_blueprint

View File

@ -5,7 +5,7 @@ from socket import gaierror
from werkzeug.utils import secure_filename
from .. import db, socketio
from ..decorators import socketio_login_required
from ..socketio_events import socketio_sessions
from ..events.socketio import sessions as socketio_sessions
from ..models import Corpus
import cqi
import math

View File

@ -1,9 +1,9 @@
from flask import request
from flask_login import current_user
from flask_socketio import join_room, leave_room
from . import socketio
from .decorators import socketio_login_required
from .models import User
from .. import socketio
from ..decorators import socketio_login_required
from ..models import User
'''
@ -11,7 +11,7 @@ from .models import User
' of all connected sessions, which can be used to determine the runtimes of
' associated background tasks.
'''
socketio_sessions = []
sessions = []
###############################################################################
@ -24,7 +24,7 @@ def socketio_connect():
' The Socket.IO module creates a session id (sid) for each request.
' On connect the sid is saved in the connected sessions list.
'''
socketio_sessions.append(request.sid)
sessions.append(request.sid)
@socketio.on('disconnect')
@ -34,7 +34,7 @@ def socketio_disconnect():
' list.
'''
try:
socketio_sessions.remove(request.sid)
sessions.remove(request.sid)
except ValueError:
pass

View File

@ -1,6 +1,6 @@
from datetime import datetime
from . import db, socketio
from .models import Corpus, CorpusFile, Job, JobInput, JobResult
from .. import db, socketio
from ..models import Corpus, CorpusFile, Job, JobInput, JobResult
###############################################################################