Compare commits

...

1 Commits

Author SHA1 Message Date
Timmy
72c6952147 fix(#1356): Replace HTTPServer with ThreadingHTTPServer for concurrent users
Some checks failed
CI / test (pull_request) Failing after 46s
Review Approval Gate / verify-review (pull_request) Failing after 7s
CI / validate (pull_request) Failing after 52s
The multi-user bridge used single-threaded HTTPServer which processed
requests sequentially. Each LLM inference call (5-10s) blocked all
other users, causing 60% timeout rate at 10 concurrent connections.

Changes:
  - world/multi_user_bridge.py: Added ThreadingMixIn import,
    ThreadingHTTPServer class with daemon_threads, swapped
    HTTPServer -> ThreadingHTTPServer in main()
  - multi_user_bridge.py (root): Fixed main() to use the already-
    defined ThreadingHTTPServer class instead of raw HTTPServer

Fixes #1356
2026-04-13 18:47:25 -04:00
2 changed files with 10 additions and 3 deletions

View File

@@ -2880,7 +2880,7 @@ def main():
# Start world tick system
world_tick_system.start()
server = HTTPServer((BRIDGE_HOST, BRIDGE_PORT), BridgeHandler)
server = ThreadingHTTPServer((BRIDGE_HOST, BRIDGE_PORT), BridgeHandler)
server.serve_forever()

View File

@@ -26,11 +26,18 @@ import threading
import hashlib
import os
import sys
from http.server import HTTPServer, BaseHTTPRequestHandler
from http.server import BaseHTTPRequestHandler, HTTPServer
from socketserver import ThreadingMixIn
from pathlib import Path
from datetime import datetime
from typing import Optional
class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
"""Thread-per-request server for concurrent multi-user handling."""
daemon_threads = True
# ── Configuration ──────────────────────────────────────────────────────
BRIDGE_PORT = int(os.environ.get('TIMMY_BRIDGE_PORT', 4004))
@@ -274,7 +281,7 @@ def main():
print(f" POST /bridge/move — Move user to room (user_id, room)")
print()
server = HTTPServer((BRIDGE_HOST, BRIDGE_PORT), BridgeHandler)
server = ThreadingHTTPServer((BRIDGE_HOST, BRIDGE_PORT), BridgeHandler)
server.serve_forever()