From 51f64be02531b0a1bf01720cd2b523738df82a17 Mon Sep 17 00:00:00 2001 From: MarekWo Date: Sat, 10 Jan 2026 14:42:33 +0100 Subject: [PATCH] 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 --- app/main.py | 4 +++- requirements.txt | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/main.py b/app/main.py index f4e95cd..6531274 100644 --- a/app/main.py +++ b/app/main.py @@ -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: diff --git a/requirements.txt b/requirements.txt index 54deac8..6222dbc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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