mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-07-21 09:03:02 +02:00
fix: Add request locking and caching to prevent USB conflicts
Root cause: Multiple concurrent meshcli calls were fighting for USB access, causing "Protocol error" and 504 Gateway Timeouts. Changes to meshcore-bridge: - Add threading.Lock to serialize meshcli subprocess calls - Prevent concurrent USB access that causes OSError [Errno 71] - Reduce DEFAULT_TIMEOUT from 30s to 10s - Add detailed logging for lock acquisition and release Changes to main API: - Implement 30s cache for get_channels() to reduce USB calls - Cache invalidation after channel create/join/delete operations - Use cached channels in /api/channels and /api/messages/updates - Reduce HTTP timeout from 30s to 12s (10s bridge + 2s buffer) Impact: - Eliminates race conditions when page loads (multiple API calls) - Prevents USB port conflicts and protocol errors - Faster response times due to caching - No need for manual USB resets after container restarts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -10,8 +10,8 @@ from app.config import config
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Command timeout in seconds
|
||||
DEFAULT_TIMEOUT = 30
|
||||
# Command timeout in seconds (reduced to prevent long waits)
|
||||
DEFAULT_TIMEOUT = 12 # Reduced from 30s - bridge has 10s + 2s buffer
|
||||
RECV_TIMEOUT = 60 # recv can take longer
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user