perf: Switch SocketIO from gevent to threading mode

gevent async_mode requires monkey-patching at startup and was causing
6-12s page load times (vs 1-2s before). Threading mode doesn't require
special setup and is sufficient for occasional Console commands.

- Change async_mode from 'gevent' to 'threading'
- Remove gevent/gevent-websocket from requirements (bridge has its own)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-01-10 14:42:33 +01:00
parent 195eb10ad9
commit 51f64be025
2 changed files with 4 additions and 4 deletions

View File

@@ -46,7 +46,9 @@ def create_app():
app.register_blueprint(api_bp)
# Initialize SocketIO with the app
socketio.init_app(app, cors_allowed_origins="*", async_mode='gevent')
# Using 'threading' mode for better compatibility with regular HTTP requests
# (gevent mode requires monkey-patching and slows down non-WebSocket requests)
socketio.init_app(app, cors_allowed_origins="*", async_mode='threading')
# Initialize archive scheduler if enabled
if config.MC_ARCHIVE_ENABLED:

View File

@@ -23,9 +23,7 @@ Pillow==10.1.0
# HTTP Client for MeshCore Bridge communication
requests==2.31.0
# WebSocket support for console
# WebSocket support for console (threading mode - no gevent needed)
flask-socketio==5.3.6
python-socketio==5.10.0
python-engineio==4.8.1
gevent==23.9.1
gevent-websocket==0.10.1